
obj/user/sh.debug:     file format elf32-i386


Disassembly of section .text:

00800020 <_start>:
// starts us running when we are initially loaded into a new environment.
.text
.globl _start
_start:
	// See if we were started with arguments on the stack
	cmpl $USTACKTOP, %esp
  800020:	81 fc 00 e0 bf ee    	cmp    $0xeebfe000,%esp
	jne args_exist
  800026:	75 04                	jne    80002c <args_exist>

	// If not, push dummy argc/argv arguments.
	// This happens when we are loaded by the kernel,
	// because the kernel does not know about passing arguments.
	pushl $0
  800028:	6a 00                	push   $0x0
	pushl $0
  80002a:	6a 00                	push   $0x0

0080002c <args_exist>:

args_exist:
	call libmain
  80002c:	e8 0d 0a 00 00       	call   800a3e <libmain>
1:	jmp 1b
  800031:	eb fe                	jmp    800031 <args_exist+0x5>

00800033 <_gettoken>:
#define WHITESPACE " \t\r\n"
#define SYMBOLS "<|>&;()"

int
_gettoken(char *s, char **p1, char **p2)
{
  800033:	f3 0f 1e fb          	endbr32 
  800037:	55                   	push   %ebp
  800038:	89 e5                	mov    %esp,%ebp
  80003a:	57                   	push   %edi
  80003b:	56                   	push   %esi
  80003c:	53                   	push   %ebx
  80003d:	83 ec 0c             	sub    $0xc,%esp
  800040:	8b 5d 08             	mov    0x8(%ebp),%ebx
  800043:	8b 7d 0c             	mov    0xc(%ebp),%edi
	int t;

	if (s == 0) {
  800046:	85 db                	test   %ebx,%ebx
  800048:	74 1a                	je     800064 <_gettoken+0x31>
		if (debug > 1)
			cprintf("GETTOKEN NULL\n");
		return 0;
	}

	if (debug > 1)
  80004a:	83 3d 00 50 80 00 01 	cmpl   $0x1,0x805000
  800051:	7f 31                	jg     800084 <_gettoken+0x51>
		cprintf("GETTOKEN: %s\n", s);

	*p1 = 0;
  800053:	c7 07 00 00 00 00    	movl   $0x0,(%edi)
	*p2 = 0;
  800059:	8b 45 10             	mov    0x10(%ebp),%eax
  80005c:	c7 00 00 00 00 00    	movl   $0x0,(%eax)

	while (strchr(WHITESPACE, *s))
  800062:	eb 3a                	jmp    80009e <_gettoken+0x6b>
		return 0;
  800064:	be 00 00 00 00       	mov    $0x0,%esi
		if (debug > 1)
  800069:	83 3d 00 50 80 00 01 	cmpl   $0x1,0x805000
  800070:	7e 59                	jle    8000cb <_gettoken+0x98>
			cprintf("GETTOKEN NULL\n");
  800072:	83 ec 0c             	sub    $0xc,%esp
  800075:	68 00 35 80 00       	push   $0x803500
  80007a:	e8 18 0b 00 00       	call   800b97 <cprintf>
  80007f:	83 c4 10             	add    $0x10,%esp
  800082:	eb 47                	jmp    8000cb <_gettoken+0x98>
		cprintf("GETTOKEN: %s\n", s);
  800084:	83 ec 08             	sub    $0x8,%esp
  800087:	53                   	push   %ebx
  800088:	68 0f 35 80 00       	push   $0x80350f
  80008d:	e8 05 0b 00 00       	call   800b97 <cprintf>
  800092:	83 c4 10             	add    $0x10,%esp
  800095:	eb bc                	jmp    800053 <_gettoken+0x20>
		*s++ = 0;
  800097:	83 c3 01             	add    $0x1,%ebx
  80009a:	c6 43 ff 00          	movb   $0x0,-0x1(%ebx)
	while (strchr(WHITESPACE, *s))
  80009e:	83 ec 08             	sub    $0x8,%esp
  8000a1:	0f be 03             	movsbl (%ebx),%eax
  8000a4:	50                   	push   %eax
  8000a5:	68 1d 35 80 00       	push   $0x80351d
  8000aa:	e8 da 12 00 00       	call   801389 <strchr>
  8000af:	83 c4 10             	add    $0x10,%esp
  8000b2:	85 c0                	test   %eax,%eax
  8000b4:	75 e1                	jne    800097 <_gettoken+0x64>
	if (*s == 0) {
  8000b6:	0f b6 03             	movzbl (%ebx),%eax
  8000b9:	84 c0                	test   %al,%al
  8000bb:	75 2a                	jne    8000e7 <_gettoken+0xb4>
		if (debug > 1)
			cprintf("EOL\n");
		return 0;
  8000bd:	be 00 00 00 00       	mov    $0x0,%esi
		if (debug > 1)
  8000c2:	83 3d 00 50 80 00 01 	cmpl   $0x1,0x805000
  8000c9:	7f 0a                	jg     8000d5 <_gettoken+0xa2>
		**p2 = 0;
		cprintf("WORD: %s\n", *p1);
		**p2 = t;
	}
	return 'w';
}
  8000cb:	89 f0                	mov    %esi,%eax
  8000cd:	8d 65 f4             	lea    -0xc(%ebp),%esp
  8000d0:	5b                   	pop    %ebx
  8000d1:	5e                   	pop    %esi
  8000d2:	5f                   	pop    %edi
  8000d3:	5d                   	pop    %ebp
  8000d4:	c3                   	ret    
			cprintf("EOL\n");
  8000d5:	83 ec 0c             	sub    $0xc,%esp
  8000d8:	68 22 35 80 00       	push   $0x803522
  8000dd:	e8 b5 0a 00 00       	call   800b97 <cprintf>
  8000e2:	83 c4 10             	add    $0x10,%esp
  8000e5:	eb e4                	jmp    8000cb <_gettoken+0x98>
	if (strchr(SYMBOLS, *s)) {
  8000e7:	83 ec 08             	sub    $0x8,%esp
  8000ea:	0f be c0             	movsbl %al,%eax
  8000ed:	50                   	push   %eax
  8000ee:	68 33 35 80 00       	push   $0x803533
  8000f3:	e8 91 12 00 00       	call   801389 <strchr>
  8000f8:	83 c4 10             	add    $0x10,%esp
  8000fb:	85 c0                	test   %eax,%eax
  8000fd:	74 2c                	je     80012b <_gettoken+0xf8>
		t = *s;
  8000ff:	0f be 33             	movsbl (%ebx),%esi
		*p1 = s;
  800102:	89 1f                	mov    %ebx,(%edi)
		*s++ = 0;
  800104:	c6 03 00             	movb   $0x0,(%ebx)
  800107:	83 c3 01             	add    $0x1,%ebx
  80010a:	8b 45 10             	mov    0x10(%ebp),%eax
  80010d:	89 18                	mov    %ebx,(%eax)
		if (debug > 1)
  80010f:	83 3d 00 50 80 00 01 	cmpl   $0x1,0x805000
  800116:	7e b3                	jle    8000cb <_gettoken+0x98>
			cprintf("TOK %c\n", t);
  800118:	83 ec 08             	sub    $0x8,%esp
  80011b:	56                   	push   %esi
  80011c:	68 27 35 80 00       	push   $0x803527
  800121:	e8 71 0a 00 00       	call   800b97 <cprintf>
  800126:	83 c4 10             	add    $0x10,%esp
  800129:	eb a0                	jmp    8000cb <_gettoken+0x98>
	*p1 = s;
  80012b:	89 1f                	mov    %ebx,(%edi)
	while (*s && !strchr(WHITESPACE SYMBOLS, *s))
  80012d:	eb 03                	jmp    800132 <_gettoken+0xff>
		s++;
  80012f:	83 c3 01             	add    $0x1,%ebx
	while (*s && !strchr(WHITESPACE SYMBOLS, *s))
  800132:	0f b6 03             	movzbl (%ebx),%eax
  800135:	84 c0                	test   %al,%al
  800137:	74 18                	je     800151 <_gettoken+0x11e>
  800139:	83 ec 08             	sub    $0x8,%esp
  80013c:	0f be c0             	movsbl %al,%eax
  80013f:	50                   	push   %eax
  800140:	68 2f 35 80 00       	push   $0x80352f
  800145:	e8 3f 12 00 00       	call   801389 <strchr>
  80014a:	83 c4 10             	add    $0x10,%esp
  80014d:	85 c0                	test   %eax,%eax
  80014f:	74 de                	je     80012f <_gettoken+0xfc>
	*p2 = s;
  800151:	8b 45 10             	mov    0x10(%ebp),%eax
  800154:	89 18                	mov    %ebx,(%eax)
	return 'w';
  800156:	be 77 00 00 00       	mov    $0x77,%esi
	if (debug > 1) {
  80015b:	83 3d 00 50 80 00 01 	cmpl   $0x1,0x805000
  800162:	0f 8e 63 ff ff ff    	jle    8000cb <_gettoken+0x98>
		t = **p2;
  800168:	0f b6 33             	movzbl (%ebx),%esi
		**p2 = 0;
  80016b:	c6 03 00             	movb   $0x0,(%ebx)
		cprintf("WORD: %s\n", *p1);
  80016e:	83 ec 08             	sub    $0x8,%esp
  800171:	ff 37                	pushl  (%edi)
  800173:	68 3b 35 80 00       	push   $0x80353b
  800178:	e8 1a 0a 00 00       	call   800b97 <cprintf>
		**p2 = t;
  80017d:	8b 45 10             	mov    0x10(%ebp),%eax
  800180:	8b 00                	mov    (%eax),%eax
  800182:	89 f2                	mov    %esi,%edx
  800184:	88 10                	mov    %dl,(%eax)
  800186:	83 c4 10             	add    $0x10,%esp
	return 'w';
  800189:	be 77 00 00 00       	mov    $0x77,%esi
  80018e:	e9 38 ff ff ff       	jmp    8000cb <_gettoken+0x98>

00800193 <gettoken>:

int
gettoken(char *s, char **p1)
{
  800193:	f3 0f 1e fb          	endbr32 
  800197:	55                   	push   %ebp
  800198:	89 e5                	mov    %esp,%ebp
  80019a:	83 ec 08             	sub    $0x8,%esp
  80019d:	8b 45 08             	mov    0x8(%ebp),%eax
	static int c, nc;
	static char* np1, *np2;

	if (s) {
  8001a0:	85 c0                	test   %eax,%eax
  8001a2:	74 22                	je     8001c6 <gettoken+0x33>
		nc = _gettoken(s, &np1, &np2);
  8001a4:	83 ec 04             	sub    $0x4,%esp
  8001a7:	68 0c 50 80 00       	push   $0x80500c
  8001ac:	68 10 50 80 00       	push   $0x805010
  8001b1:	50                   	push   %eax
  8001b2:	e8 7c fe ff ff       	call   800033 <_gettoken>
  8001b7:	a3 08 50 80 00       	mov    %eax,0x805008
		return 0;
  8001bc:	83 c4 10             	add    $0x10,%esp
  8001bf:	b8 00 00 00 00       	mov    $0x0,%eax
	}
	c = nc;
	*p1 = np1;
	nc = _gettoken(np2, &np1, &np2);
	return c;
}
  8001c4:	c9                   	leave  
  8001c5:	c3                   	ret    
	c = nc;
  8001c6:	a1 08 50 80 00       	mov    0x805008,%eax
  8001cb:	a3 04 50 80 00       	mov    %eax,0x805004
	*p1 = np1;
  8001d0:	8b 15 10 50 80 00    	mov    0x805010,%edx
  8001d6:	8b 45 0c             	mov    0xc(%ebp),%eax
  8001d9:	89 10                	mov    %edx,(%eax)
	nc = _gettoken(np2, &np1, &np2);
  8001db:	83 ec 04             	sub    $0x4,%esp
  8001de:	68 0c 50 80 00       	push   $0x80500c
  8001e3:	68 10 50 80 00       	push   $0x805010
  8001e8:	ff 35 0c 50 80 00    	pushl  0x80500c
  8001ee:	e8 40 fe ff ff       	call   800033 <_gettoken>
  8001f3:	a3 08 50 80 00       	mov    %eax,0x805008
	return c;
  8001f8:	a1 04 50 80 00       	mov    0x805004,%eax
  8001fd:	83 c4 10             	add    $0x10,%esp
  800200:	eb c2                	jmp    8001c4 <gettoken+0x31>

00800202 <runcmd>:
{
  800202:	f3 0f 1e fb          	endbr32 
  800206:	55                   	push   %ebp
  800207:	89 e5                	mov    %esp,%ebp
  800209:	57                   	push   %edi
  80020a:	56                   	push   %esi
  80020b:	53                   	push   %ebx
  80020c:	81 ec 64 04 00 00    	sub    $0x464,%esp
	gettoken(s, 0);
  800212:	6a 00                	push   $0x0
  800214:	ff 75 08             	pushl  0x8(%ebp)
  800217:	e8 77 ff ff ff       	call   800193 <gettoken>
  80021c:	83 c4 10             	add    $0x10,%esp
		switch ((c = gettoken(0, &t))) {
  80021f:	8d 75 a4             	lea    -0x5c(%ebp),%esi
	argc = 0;
  800222:	bf 00 00 00 00       	mov    $0x0,%edi
		switch ((c = gettoken(0, &t))) {
  800227:	83 ec 08             	sub    $0x8,%esp
  80022a:	56                   	push   %esi
  80022b:	6a 00                	push   $0x0
  80022d:	e8 61 ff ff ff       	call   800193 <gettoken>
  800232:	89 c3                	mov    %eax,%ebx
  800234:	83 c4 10             	add    $0x10,%esp
  800237:	83 f8 3e             	cmp    $0x3e,%eax
  80023a:	0f 84 32 01 00 00    	je     800372 <runcmd+0x170>
  800240:	7f 49                	jg     80028b <runcmd+0x89>
  800242:	85 c0                	test   %eax,%eax
  800244:	0f 84 1c 02 00 00    	je     800466 <runcmd+0x264>
  80024a:	83 f8 3c             	cmp    $0x3c,%eax
  80024d:	0f 85 ef 02 00 00    	jne    800542 <runcmd+0x340>
			if (gettoken(0, &t) != 'w') {
  800253:	83 ec 08             	sub    $0x8,%esp
  800256:	56                   	push   %esi
  800257:	6a 00                	push   $0x0
  800259:	e8 35 ff ff ff       	call   800193 <gettoken>
  80025e:	83 c4 10             	add    $0x10,%esp
  800261:	83 f8 77             	cmp    $0x77,%eax
  800264:	0f 85 ba 00 00 00    	jne    800324 <runcmd+0x122>
			if ((fd = open(t, O_RDONLY)) < 0) {
  80026a:	83 ec 08             	sub    $0x8,%esp
  80026d:	6a 00                	push   $0x0
  80026f:	ff 75 a4             	pushl  -0x5c(%ebp)
  800272:	e8 7d 22 00 00       	call   8024f4 <open>
  800277:	89 c3                	mov    %eax,%ebx
  800279:	83 c4 10             	add    $0x10,%esp
  80027c:	85 c0                	test   %eax,%eax
  80027e:	0f 88 ba 00 00 00    	js     80033e <runcmd+0x13c>
		    if (fd != 0) {
  800284:	74 a1                	je     800227 <runcmd+0x25>
  800286:	e9 cc 00 00 00       	jmp    800357 <runcmd+0x155>
		switch ((c = gettoken(0, &t))) {
  80028b:	83 f8 77             	cmp    $0x77,%eax
  80028e:	74 69                	je     8002f9 <runcmd+0xf7>
  800290:	83 f8 7c             	cmp    $0x7c,%eax
  800293:	0f 85 a9 02 00 00    	jne    800542 <runcmd+0x340>
			if ((r = pipe(p)) < 0) {
  800299:	83 ec 0c             	sub    $0xc,%esp
  80029c:	8d 85 9c fb ff ff    	lea    -0x464(%ebp),%eax
  8002a2:	50                   	push   %eax
  8002a3:	e8 0a 2c 00 00       	call   802eb2 <pipe>
  8002a8:	83 c4 10             	add    $0x10,%esp
  8002ab:	85 c0                	test   %eax,%eax
  8002ad:	0f 88 41 01 00 00    	js     8003f4 <runcmd+0x1f2>
			if (debug)
  8002b3:	83 3d 00 50 80 00 00 	cmpl   $0x0,0x805000
  8002ba:	0f 85 4f 01 00 00    	jne    80040f <runcmd+0x20d>
			if ((r = fork()) < 0) {
  8002c0:	e8 18 17 00 00       	call   8019dd <fork>
  8002c5:	89 c3                	mov    %eax,%ebx
  8002c7:	85 c0                	test   %eax,%eax
  8002c9:	0f 88 61 01 00 00    	js     800430 <runcmd+0x22e>
			if (r == 0) {
  8002cf:	0f 85 71 01 00 00    	jne    800446 <runcmd+0x244>
				if (p[0] != 0) {
  8002d5:	8b 85 9c fb ff ff    	mov    -0x464(%ebp),%eax
  8002db:	85 c0                	test   %eax,%eax
  8002dd:	0f 85 1d 02 00 00    	jne    800500 <runcmd+0x2fe>
				close(p[1]);
  8002e3:	83 ec 0c             	sub    $0xc,%esp
  8002e6:	ff b5 a0 fb ff ff    	pushl  -0x460(%ebp)
  8002ec:	e8 24 1c 00 00       	call   801f15 <close>
				goto again;
  8002f1:	83 c4 10             	add    $0x10,%esp
  8002f4:	e9 29 ff ff ff       	jmp    800222 <runcmd+0x20>
			if (argc == MAXARGS) {
  8002f9:	83 ff 10             	cmp    $0x10,%edi
  8002fc:	74 0f                	je     80030d <runcmd+0x10b>
			argv[argc++] = t;
  8002fe:	8b 45 a4             	mov    -0x5c(%ebp),%eax
  800301:	89 44 bd a8          	mov    %eax,-0x58(%ebp,%edi,4)
  800305:	8d 7f 01             	lea    0x1(%edi),%edi
			break;
  800308:	e9 1a ff ff ff       	jmp    800227 <runcmd+0x25>
				cprintf("too many arguments\n");
  80030d:	83 ec 0c             	sub    $0xc,%esp
  800310:	68 45 35 80 00       	push   $0x803545
  800315:	e8 7d 08 00 00       	call   800b97 <cprintf>
				exit();
  80031a:	e8 73 07 00 00       	call   800a92 <exit>
  80031f:	83 c4 10             	add    $0x10,%esp
  800322:	eb da                	jmp    8002fe <runcmd+0xfc>
				cprintf("syntax error: < not followed by word\n");
  800324:	83 ec 0c             	sub    $0xc,%esp
  800327:	68 98 36 80 00       	push   $0x803698
  80032c:	e8 66 08 00 00       	call   800b97 <cprintf>
				exit();
  800331:	e8 5c 07 00 00       	call   800a92 <exit>
  800336:	83 c4 10             	add    $0x10,%esp
  800339:	e9 2c ff ff ff       	jmp    80026a <runcmd+0x68>
			cprintf("open %s for read: %e", t, fd);
  80033e:	83 ec 04             	sub    $0x4,%esp
  800341:	50                   	push   %eax
  800342:	ff 75 a4             	pushl  -0x5c(%ebp)
  800345:	68 59 35 80 00       	push   $0x803559
  80034a:	e8 48 08 00 00       	call   800b97 <cprintf>
			exit();
  80034f:	e8 3e 07 00 00       	call   800a92 <exit>
  800354:	83 c4 10             	add    $0x10,%esp
			dup(fd, 0); 
  800357:	83 ec 08             	sub    $0x8,%esp
  80035a:	6a 00                	push   $0x0
  80035c:	53                   	push   %ebx
  80035d:	e8 0d 1c 00 00       	call   801f6f <dup>
			close(fd);
  800362:	89 1c 24             	mov    %ebx,(%esp)
  800365:	e8 ab 1b 00 00       	call   801f15 <close>
  80036a:	83 c4 10             	add    $0x10,%esp
  80036d:	e9 b5 fe ff ff       	jmp    800227 <runcmd+0x25>
			if (gettoken(0, &t) != 'w') {
  800372:	83 ec 08             	sub    $0x8,%esp
  800375:	56                   	push   %esi
  800376:	6a 00                	push   $0x0
  800378:	e8 16 fe ff ff       	call   800193 <gettoken>
  80037d:	83 c4 10             	add    $0x10,%esp
  800380:	83 f8 77             	cmp    $0x77,%eax
  800383:	75 24                	jne    8003a9 <runcmd+0x1a7>
			if ((fd = open(t, O_WRONLY|O_CREAT|O_TRUNC)) < 0) {
  800385:	83 ec 08             	sub    $0x8,%esp
  800388:	68 01 03 00 00       	push   $0x301
  80038d:	ff 75 a4             	pushl  -0x5c(%ebp)
  800390:	e8 5f 21 00 00       	call   8024f4 <open>
  800395:	89 c3                	mov    %eax,%ebx
  800397:	83 c4 10             	add    $0x10,%esp
  80039a:	85 c0                	test   %eax,%eax
  80039c:	78 22                	js     8003c0 <runcmd+0x1be>
			if (fd != 1) {
  80039e:	83 f8 01             	cmp    $0x1,%eax
  8003a1:	0f 84 80 fe ff ff    	je     800227 <runcmd+0x25>
  8003a7:	eb 30                	jmp    8003d9 <runcmd+0x1d7>
				cprintf("syntax error: > not followed by word\n");
  8003a9:	83 ec 0c             	sub    $0xc,%esp
  8003ac:	68 c0 36 80 00       	push   $0x8036c0
  8003b1:	e8 e1 07 00 00       	call   800b97 <cprintf>
				exit();
  8003b6:	e8 d7 06 00 00       	call   800a92 <exit>
  8003bb:	83 c4 10             	add    $0x10,%esp
  8003be:	eb c5                	jmp    800385 <runcmd+0x183>
				cprintf("open %s for write: %e", t, fd);
  8003c0:	83 ec 04             	sub    $0x4,%esp
  8003c3:	50                   	push   %eax
  8003c4:	ff 75 a4             	pushl  -0x5c(%ebp)
  8003c7:	68 6e 35 80 00       	push   $0x80356e
  8003cc:	e8 c6 07 00 00       	call   800b97 <cprintf>
				exit();
  8003d1:	e8 bc 06 00 00       	call   800a92 <exit>
  8003d6:	83 c4 10             	add    $0x10,%esp
				dup(fd, 1);
  8003d9:	83 ec 08             	sub    $0x8,%esp
  8003dc:	6a 01                	push   $0x1
  8003de:	53                   	push   %ebx
  8003df:	e8 8b 1b 00 00       	call   801f6f <dup>
				close(fd);
  8003e4:	89 1c 24             	mov    %ebx,(%esp)
  8003e7:	e8 29 1b 00 00       	call   801f15 <close>
  8003ec:	83 c4 10             	add    $0x10,%esp
  8003ef:	e9 33 fe ff ff       	jmp    800227 <runcmd+0x25>
				cprintf("pipe: %e", r);
  8003f4:	83 ec 08             	sub    $0x8,%esp
  8003f7:	50                   	push   %eax
  8003f8:	68 84 35 80 00       	push   $0x803584
  8003fd:	e8 95 07 00 00       	call   800b97 <cprintf>
				exit();
  800402:	e8 8b 06 00 00       	call   800a92 <exit>
  800407:	83 c4 10             	add    $0x10,%esp
  80040a:	e9 a4 fe ff ff       	jmp    8002b3 <runcmd+0xb1>
				cprintf("PIPE: %d %d\n", p[0], p[1]);
  80040f:	83 ec 04             	sub    $0x4,%esp
  800412:	ff b5 a0 fb ff ff    	pushl  -0x460(%ebp)
  800418:	ff b5 9c fb ff ff    	pushl  -0x464(%ebp)
  80041e:	68 8d 35 80 00       	push   $0x80358d
  800423:	e8 6f 07 00 00       	call   800b97 <cprintf>
  800428:	83 c4 10             	add    $0x10,%esp
  80042b:	e9 90 fe ff ff       	jmp    8002c0 <runcmd+0xbe>
				cprintf("fork: %e", r);
  800430:	83 ec 08             	sub    $0x8,%esp
  800433:	50                   	push   %eax
  800434:	68 9a 35 80 00       	push   $0x80359a
  800439:	e8 59 07 00 00       	call   800b97 <cprintf>
				exit();
  80043e:	e8 4f 06 00 00       	call   800a92 <exit>
  800443:	83 c4 10             	add    $0x10,%esp
				if (p[1] != 1) {
  800446:	8b 85 a0 fb ff ff    	mov    -0x460(%ebp),%eax
  80044c:	83 f8 01             	cmp    $0x1,%eax
  80044f:	0f 85 cc 00 00 00    	jne    800521 <runcmd+0x31f>
				close(p[0]);
  800455:	83 ec 0c             	sub    $0xc,%esp
  800458:	ff b5 9c fb ff ff    	pushl  -0x464(%ebp)
  80045e:	e8 b2 1a 00 00       	call   801f15 <close>
				goto runit;
  800463:	83 c4 10             	add    $0x10,%esp
	if(argc == 0) {
  800466:	85 ff                	test   %edi,%edi
  800468:	0f 84 e6 00 00 00    	je     800554 <runcmd+0x352>
	if (argv[0][0] != '/') {
  80046e:	8b 45 a8             	mov    -0x58(%ebp),%eax
  800471:	80 38 2f             	cmpb   $0x2f,(%eax)
  800474:	0f 85 f5 00 00 00    	jne    80056f <runcmd+0x36d>
	argv[argc] = 0;
  80047a:	c7 44 bd a8 00 00 00 	movl   $0x0,-0x58(%ebp,%edi,4)
  800481:	00 
	if (debug) {
  800482:	83 3d 00 50 80 00 00 	cmpl   $0x0,0x805000
  800489:	0f 85 08 01 00 00    	jne    800597 <runcmd+0x395>
	if ((r = spawn(argv[0], (const char**) argv)) < 0)
  80048f:	83 ec 08             	sub    $0x8,%esp
  800492:	8d 45 a8             	lea    -0x58(%ebp),%eax
  800495:	50                   	push   %eax
  800496:	ff 75 a8             	pushl  -0x58(%ebp)
  800499:	e8 27 22 00 00       	call   8026c5 <spawn>
  80049e:	89 c6                	mov    %eax,%esi
  8004a0:	83 c4 10             	add    $0x10,%esp
  8004a3:	85 c0                	test   %eax,%eax
  8004a5:	0f 88 3a 01 00 00    	js     8005e5 <runcmd+0x3e3>
	close_all();
  8004ab:	e8 96 1a 00 00       	call   801f46 <close_all>
		if (debug)
  8004b0:	83 3d 00 50 80 00 00 	cmpl   $0x0,0x805000
  8004b7:	0f 85 75 01 00 00    	jne    800632 <runcmd+0x430>
		wait(r);
  8004bd:	83 ec 0c             	sub    $0xc,%esp
  8004c0:	56                   	push   %esi
  8004c1:	e8 71 2b 00 00       	call   803037 <wait>
		if (debug)
  8004c6:	83 c4 10             	add    $0x10,%esp
  8004c9:	83 3d 00 50 80 00 00 	cmpl   $0x0,0x805000
  8004d0:	0f 85 7b 01 00 00    	jne    800651 <runcmd+0x44f>
	if (pipe_child) {
  8004d6:	85 db                	test   %ebx,%ebx
  8004d8:	74 19                	je     8004f3 <runcmd+0x2f1>
		wait(pipe_child);
  8004da:	83 ec 0c             	sub    $0xc,%esp
  8004dd:	53                   	push   %ebx
  8004de:	e8 54 2b 00 00       	call   803037 <wait>
		if (debug)
  8004e3:	83 c4 10             	add    $0x10,%esp
  8004e6:	83 3d 00 50 80 00 00 	cmpl   $0x0,0x805000
  8004ed:	0f 85 79 01 00 00    	jne    80066c <runcmd+0x46a>
	exit();
  8004f3:	e8 9a 05 00 00       	call   800a92 <exit>
}
  8004f8:	8d 65 f4             	lea    -0xc(%ebp),%esp
  8004fb:	5b                   	pop    %ebx
  8004fc:	5e                   	pop    %esi
  8004fd:	5f                   	pop    %edi
  8004fe:	5d                   	pop    %ebp
  8004ff:	c3                   	ret    
					dup(p[0], 0);
  800500:	83 ec 08             	sub    $0x8,%esp
  800503:	6a 00                	push   $0x0
  800505:	50                   	push   %eax
  800506:	e8 64 1a 00 00       	call   801f6f <dup>
					close(p[0]);
  80050b:	83 c4 04             	add    $0x4,%esp
  80050e:	ff b5 9c fb ff ff    	pushl  -0x464(%ebp)
  800514:	e8 fc 19 00 00       	call   801f15 <close>
  800519:	83 c4 10             	add    $0x10,%esp
  80051c:	e9 c2 fd ff ff       	jmp    8002e3 <runcmd+0xe1>
					dup(p[1], 1);
  800521:	83 ec 08             	sub    $0x8,%esp
  800524:	6a 01                	push   $0x1
  800526:	50                   	push   %eax
  800527:	e8 43 1a 00 00       	call   801f6f <dup>
					close(p[1]);
  80052c:	83 c4 04             	add    $0x4,%esp
  80052f:	ff b5 a0 fb ff ff    	pushl  -0x460(%ebp)
  800535:	e8 db 19 00 00       	call   801f15 <close>
  80053a:	83 c4 10             	add    $0x10,%esp
  80053d:	e9 13 ff ff ff       	jmp    800455 <runcmd+0x253>
			panic("bad return %d from gettoken", c);
  800542:	53                   	push   %ebx
  800543:	68 a3 35 80 00       	push   $0x8035a3
  800548:	6a 78                	push   $0x78
  80054a:	68 bf 35 80 00       	push   $0x8035bf
  80054f:	e8 5c 05 00 00       	call   800ab0 <_panic>
		if (debug)
  800554:	83 3d 00 50 80 00 00 	cmpl   $0x0,0x805000
  80055b:	74 9b                	je     8004f8 <runcmd+0x2f6>
			cprintf("EMPTY COMMAND\n");
  80055d:	83 ec 0c             	sub    $0xc,%esp
  800560:	68 c9 35 80 00       	push   $0x8035c9
  800565:	e8 2d 06 00 00       	call   800b97 <cprintf>
  80056a:	83 c4 10             	add    $0x10,%esp
  80056d:	eb 89                	jmp    8004f8 <runcmd+0x2f6>
		argv0buf[0] = '/';
  80056f:	c6 85 a4 fb ff ff 2f 	movb   $0x2f,-0x45c(%ebp)
		strcpy(argv0buf + 1, argv[0]);
  800576:	83 ec 08             	sub    $0x8,%esp
  800579:	50                   	push   %eax
  80057a:	8d b5 a4 fb ff ff    	lea    -0x45c(%ebp),%esi
  800580:	8d 85 a5 fb ff ff    	lea    -0x45b(%ebp),%eax
  800586:	50                   	push   %eax
  800587:	e8 d8 0c 00 00       	call   801264 <strcpy>
		argv[0] = argv0buf;
  80058c:	89 75 a8             	mov    %esi,-0x58(%ebp)
  80058f:	83 c4 10             	add    $0x10,%esp
  800592:	e9 e3 fe ff ff       	jmp    80047a <runcmd+0x278>
		cprintf("[%08x] SPAWN:", thisenv->env_id);
  800597:	a1 24 54 80 00       	mov    0x805424,%eax
  80059c:	8b 40 48             	mov    0x48(%eax),%eax
  80059f:	83 ec 08             	sub    $0x8,%esp
  8005a2:	50                   	push   %eax
  8005a3:	68 d8 35 80 00       	push   $0x8035d8
  8005a8:	e8 ea 05 00 00       	call   800b97 <cprintf>
  8005ad:	8d 75 a8             	lea    -0x58(%ebp),%esi
		for (i = 0; argv[i]; i++)
  8005b0:	83 c4 10             	add    $0x10,%esp
  8005b3:	eb 11                	jmp    8005c6 <runcmd+0x3c4>
			cprintf(" %s", argv[i]);
  8005b5:	83 ec 08             	sub    $0x8,%esp
  8005b8:	50                   	push   %eax
  8005b9:	68 60 36 80 00       	push   $0x803660
  8005be:	e8 d4 05 00 00       	call   800b97 <cprintf>
  8005c3:	83 c4 10             	add    $0x10,%esp
  8005c6:	83 c6 04             	add    $0x4,%esi
		for (i = 0; argv[i]; i++)
  8005c9:	8b 46 fc             	mov    -0x4(%esi),%eax
  8005cc:	85 c0                	test   %eax,%eax
  8005ce:	75 e5                	jne    8005b5 <runcmd+0x3b3>
		cprintf("\n");
  8005d0:	83 ec 0c             	sub    $0xc,%esp
  8005d3:	68 20 35 80 00       	push   $0x803520
  8005d8:	e8 ba 05 00 00       	call   800b97 <cprintf>
  8005dd:	83 c4 10             	add    $0x10,%esp
  8005e0:	e9 aa fe ff ff       	jmp    80048f <runcmd+0x28d>
		cprintf("spawn %s: %e\n", argv[0], r);
  8005e5:	83 ec 04             	sub    $0x4,%esp
  8005e8:	50                   	push   %eax
  8005e9:	ff 75 a8             	pushl  -0x58(%ebp)
  8005ec:	68 e6 35 80 00       	push   $0x8035e6
  8005f1:	e8 a1 05 00 00       	call   800b97 <cprintf>
	close_all();
  8005f6:	e8 4b 19 00 00       	call   801f46 <close_all>
  8005fb:	83 c4 10             	add    $0x10,%esp
	if (pipe_child) {
  8005fe:	85 db                	test   %ebx,%ebx
  800600:	0f 84 ed fe ff ff    	je     8004f3 <runcmd+0x2f1>
		if (debug)
  800606:	83 3d 00 50 80 00 00 	cmpl   $0x0,0x805000
  80060d:	0f 84 c7 fe ff ff    	je     8004da <runcmd+0x2d8>
			cprintf("[%08x] WAIT pipe_child %08x\n", thisenv->env_id, pipe_child);
  800613:	a1 24 54 80 00       	mov    0x805424,%eax
  800618:	8b 40 48             	mov    0x48(%eax),%eax
  80061b:	83 ec 04             	sub    $0x4,%esp
  80061e:	53                   	push   %ebx
  80061f:	50                   	push   %eax
  800620:	68 1f 36 80 00       	push   $0x80361f
  800625:	e8 6d 05 00 00       	call   800b97 <cprintf>
  80062a:	83 c4 10             	add    $0x10,%esp
  80062d:	e9 a8 fe ff ff       	jmp    8004da <runcmd+0x2d8>
			cprintf("[%08x] WAIT %s %08x\n", thisenv->env_id, argv[0], r);
  800632:	a1 24 54 80 00       	mov    0x805424,%eax
  800637:	8b 40 48             	mov    0x48(%eax),%eax
  80063a:	56                   	push   %esi
  80063b:	ff 75 a8             	pushl  -0x58(%ebp)
  80063e:	50                   	push   %eax
  80063f:	68 f4 35 80 00       	push   $0x8035f4
  800644:	e8 4e 05 00 00       	call   800b97 <cprintf>
  800649:	83 c4 10             	add    $0x10,%esp
  80064c:	e9 6c fe ff ff       	jmp    8004bd <runcmd+0x2bb>
			cprintf("[%08x] wait finished\n", thisenv->env_id);
  800651:	a1 24 54 80 00       	mov    0x805424,%eax
  800656:	8b 40 48             	mov    0x48(%eax),%eax
  800659:	83 ec 08             	sub    $0x8,%esp
  80065c:	50                   	push   %eax
  80065d:	68 09 36 80 00       	push   $0x803609
  800662:	e8 30 05 00 00       	call   800b97 <cprintf>
  800667:	83 c4 10             	add    $0x10,%esp
  80066a:	eb 92                	jmp    8005fe <runcmd+0x3fc>
			cprintf("[%08x] wait finished\n", thisenv->env_id);
  80066c:	a1 24 54 80 00       	mov    0x805424,%eax
  800671:	8b 40 48             	mov    0x48(%eax),%eax
  800674:	83 ec 08             	sub    $0x8,%esp
  800677:	50                   	push   %eax
  800678:	68 09 36 80 00       	push   $0x803609
  80067d:	e8 15 05 00 00       	call   800b97 <cprintf>
  800682:	83 c4 10             	add    $0x10,%esp
  800685:	e9 69 fe ff ff       	jmp    8004f3 <runcmd+0x2f1>

0080068a <usage>:


void
usage(void)
{
  80068a:	f3 0f 1e fb          	endbr32 
  80068e:	55                   	push   %ebp
  80068f:	89 e5                	mov    %esp,%ebp
  800691:	83 ec 14             	sub    $0x14,%esp
	cprintf("usage: sh [-dix] [command-file]\n");
  800694:	68 e8 36 80 00       	push   $0x8036e8
  800699:	e8 f9 04 00 00       	call   800b97 <cprintf>
	exit();
  80069e:	e8 ef 03 00 00       	call   800a92 <exit>
}
  8006a3:	83 c4 10             	add    $0x10,%esp
  8006a6:	c9                   	leave  
  8006a7:	c3                   	ret    

008006a8 <umain>:

void
umain(int argc, char **argv)
{
  8006a8:	f3 0f 1e fb          	endbr32 
  8006ac:	55                   	push   %ebp
  8006ad:	89 e5                	mov    %esp,%ebp
  8006af:	57                   	push   %edi
  8006b0:	56                   	push   %esi
  8006b1:	53                   	push   %ebx
  8006b2:	83 ec 30             	sub    $0x30,%esp
	int r, interactive, echocmds;
	struct Argstate args;

	interactive = '?';
	echocmds = 0;
	argstart(&argc, argv, &args);
  8006b5:	8d 45 d8             	lea    -0x28(%ebp),%eax
  8006b8:	50                   	push   %eax
  8006b9:	ff 75 0c             	pushl  0xc(%ebp)
  8006bc:	8d 45 08             	lea    0x8(%ebp),%eax
  8006bf:	50                   	push   %eax
  8006c0:	e8 33 15 00 00       	call   801bf8 <argstart>
	while ((r = argnext(&args)) >= 0)
  8006c5:	83 c4 10             	add    $0x10,%esp
	echocmds = 0;
  8006c8:	c7 45 d4 00 00 00 00 	movl   $0x0,-0x2c(%ebp)
	interactive = '?';
  8006cf:	bf 3f 00 00 00       	mov    $0x3f,%edi
	while ((r = argnext(&args)) >= 0)
  8006d4:	8d 5d d8             	lea    -0x28(%ebp),%ebx
		switch (r) {
		case 'd':
			debug++;
			break;
		case 'i':
			interactive = 1;
  8006d7:	be 01 00 00 00       	mov    $0x1,%esi
	while ((r = argnext(&args)) >= 0)
  8006dc:	eb 10                	jmp    8006ee <umain+0x46>
			debug++;
  8006de:	83 05 00 50 80 00 01 	addl   $0x1,0x805000
			break;
  8006e5:	eb 07                	jmp    8006ee <umain+0x46>
			interactive = 1;
  8006e7:	89 f7                	mov    %esi,%edi
  8006e9:	eb 03                	jmp    8006ee <umain+0x46>
		switch (r) {
  8006eb:	89 75 d4             	mov    %esi,-0x2c(%ebp)
	while ((r = argnext(&args)) >= 0)
  8006ee:	83 ec 0c             	sub    $0xc,%esp
  8006f1:	53                   	push   %ebx
  8006f2:	e8 35 15 00 00       	call   801c2c <argnext>
  8006f7:	83 c4 10             	add    $0x10,%esp
  8006fa:	85 c0                	test   %eax,%eax
  8006fc:	78 16                	js     800714 <umain+0x6c>
		switch (r) {
  8006fe:	83 f8 69             	cmp    $0x69,%eax
  800701:	74 e4                	je     8006e7 <umain+0x3f>
  800703:	83 f8 78             	cmp    $0x78,%eax
  800706:	74 e3                	je     8006eb <umain+0x43>
  800708:	83 f8 64             	cmp    $0x64,%eax
  80070b:	74 d1                	je     8006de <umain+0x36>
			break;
		case 'x':
			echocmds = 1;
			break;
		default:
			usage();
  80070d:	e8 78 ff ff ff       	call   80068a <usage>
  800712:	eb da                	jmp    8006ee <umain+0x46>
		}

	if (argc > 2)
  800714:	83 7d 08 02          	cmpl   $0x2,0x8(%ebp)
  800718:	7f 1f                	jg     800739 <umain+0x91>
		usage();
	if (argc == 2) {
  80071a:	83 7d 08 02          	cmpl   $0x2,0x8(%ebp)
  80071e:	74 20                	je     800740 <umain+0x98>
		close(0);
		if ((r = open(argv[1], O_RDONLY)) < 0)
			panic("open %s: %e", argv[1], r);
		assert(r == 0);
	}
	if (interactive == '?')
  800720:	83 ff 3f             	cmp    $0x3f,%edi
  800723:	74 75                	je     80079a <umain+0xf2>
  800725:	85 ff                	test   %edi,%edi
  800727:	bf 64 36 80 00       	mov    $0x803664,%edi
  80072c:	b8 00 00 00 00       	mov    $0x0,%eax
  800731:	0f 44 f8             	cmove  %eax,%edi
  800734:	e9 06 01 00 00       	jmp    80083f <umain+0x197>
		usage();
  800739:	e8 4c ff ff ff       	call   80068a <usage>
  80073e:	eb da                	jmp    80071a <umain+0x72>
		close(0);
  800740:	83 ec 0c             	sub    $0xc,%esp
  800743:	6a 00                	push   $0x0
  800745:	e8 cb 17 00 00       	call   801f15 <close>
		if ((r = open(argv[1], O_RDONLY)) < 0)
  80074a:	83 c4 08             	add    $0x8,%esp
  80074d:	6a 00                	push   $0x0
  80074f:	8b 45 0c             	mov    0xc(%ebp),%eax
  800752:	ff 70 04             	pushl  0x4(%eax)
  800755:	e8 9a 1d 00 00       	call   8024f4 <open>
  80075a:	83 c4 10             	add    $0x10,%esp
  80075d:	85 c0                	test   %eax,%eax
  80075f:	78 1b                	js     80077c <umain+0xd4>
		assert(r == 0);
  800761:	74 bd                	je     800720 <umain+0x78>
  800763:	68 48 36 80 00       	push   $0x803648
  800768:	68 4f 36 80 00       	push   $0x80364f
  80076d:	68 29 01 00 00       	push   $0x129
  800772:	68 bf 35 80 00       	push   $0x8035bf
  800777:	e8 34 03 00 00       	call   800ab0 <_panic>
			panic("open %s: %e", argv[1], r);
  80077c:	83 ec 0c             	sub    $0xc,%esp
  80077f:	50                   	push   %eax
  800780:	8b 45 0c             	mov    0xc(%ebp),%eax
  800783:	ff 70 04             	pushl  0x4(%eax)
  800786:	68 3c 36 80 00       	push   $0x80363c
  80078b:	68 28 01 00 00       	push   $0x128
  800790:	68 bf 35 80 00       	push   $0x8035bf
  800795:	e8 16 03 00 00       	call   800ab0 <_panic>
		interactive = iscons(0);
  80079a:	83 ec 0c             	sub    $0xc,%esp
  80079d:	6a 00                	push   $0x0
  80079f:	e8 14 02 00 00       	call   8009b8 <iscons>
  8007a4:	89 c7                	mov    %eax,%edi
  8007a6:	83 c4 10             	add    $0x10,%esp
  8007a9:	e9 77 ff ff ff       	jmp    800725 <umain+0x7d>
	while (1) {
		char *buf;

		buf = readline(interactive ? "$ " : NULL);
		if (buf == NULL) {
			if (debug)
  8007ae:	83 3d 00 50 80 00 00 	cmpl   $0x0,0x805000
  8007b5:	75 0a                	jne    8007c1 <umain+0x119>
				cprintf("EXITING\n");
			exit();	// end of file
  8007b7:	e8 d6 02 00 00       	call   800a92 <exit>
  8007bc:	e9 94 00 00 00       	jmp    800855 <umain+0x1ad>
				cprintf("EXITING\n");
  8007c1:	83 ec 0c             	sub    $0xc,%esp
  8007c4:	68 67 36 80 00       	push   $0x803667
  8007c9:	e8 c9 03 00 00       	call   800b97 <cprintf>
  8007ce:	83 c4 10             	add    $0x10,%esp
  8007d1:	eb e4                	jmp    8007b7 <umain+0x10f>
		}
		if (debug)
			cprintf("LINE: %s\n", buf);
  8007d3:	83 ec 08             	sub    $0x8,%esp
  8007d6:	53                   	push   %ebx
  8007d7:	68 70 36 80 00       	push   $0x803670
  8007dc:	e8 b6 03 00 00       	call   800b97 <cprintf>
  8007e1:	83 c4 10             	add    $0x10,%esp
  8007e4:	eb 7c                	jmp    800862 <umain+0x1ba>
		if (buf[0] == '#')
			continue;
		if (echocmds)
			printf("# %s\n", buf);
  8007e6:	83 ec 08             	sub    $0x8,%esp
  8007e9:	53                   	push   %ebx
  8007ea:	68 7a 36 80 00       	push   $0x80367a
  8007ef:	e8 b7 1e 00 00       	call   8026ab <printf>
  8007f4:	83 c4 10             	add    $0x10,%esp
  8007f7:	eb 78                	jmp    800871 <umain+0x1c9>
		if (debug)
			cprintf("BEFORE FORK\n");
  8007f9:	83 ec 0c             	sub    $0xc,%esp
  8007fc:	68 80 36 80 00       	push   $0x803680
  800801:	e8 91 03 00 00       	call   800b97 <cprintf>
  800806:	83 c4 10             	add    $0x10,%esp
  800809:	eb 73                	jmp    80087e <umain+0x1d6>
		if ((r = fork()) < 0)
			panic("fork: %e", r);
  80080b:	50                   	push   %eax
  80080c:	68 9a 35 80 00       	push   $0x80359a
  800811:	68 40 01 00 00       	push   $0x140
  800816:	68 bf 35 80 00       	push   $0x8035bf
  80081b:	e8 90 02 00 00       	call   800ab0 <_panic>
		if (debug)
			cprintf("FORK: %d\n", r);
  800820:	83 ec 08             	sub    $0x8,%esp
  800823:	50                   	push   %eax
  800824:	68 8d 36 80 00       	push   $0x80368d
  800829:	e8 69 03 00 00       	call   800b97 <cprintf>
  80082e:	83 c4 10             	add    $0x10,%esp
  800831:	eb 5f                	jmp    800892 <umain+0x1ea>
		if (r == 0) {
			runcmd(buf);
			exit();
		} else
			wait(r);
  800833:	83 ec 0c             	sub    $0xc,%esp
  800836:	56                   	push   %esi
  800837:	e8 fb 27 00 00       	call   803037 <wait>
  80083c:	83 c4 10             	add    $0x10,%esp
		buf = readline(interactive ? "$ " : NULL);
  80083f:	83 ec 0c             	sub    $0xc,%esp
  800842:	57                   	push   %edi
  800843:	e8 e5 08 00 00       	call   80112d <readline>
  800848:	89 c3                	mov    %eax,%ebx
		if (buf == NULL) {
  80084a:	83 c4 10             	add    $0x10,%esp
  80084d:	85 c0                	test   %eax,%eax
  80084f:	0f 84 59 ff ff ff    	je     8007ae <umain+0x106>
		if (debug)
  800855:	83 3d 00 50 80 00 00 	cmpl   $0x0,0x805000
  80085c:	0f 85 71 ff ff ff    	jne    8007d3 <umain+0x12b>
		if (buf[0] == '#')
  800862:	80 3b 23             	cmpb   $0x23,(%ebx)
  800865:	74 d8                	je     80083f <umain+0x197>
		if (echocmds)
  800867:	83 7d d4 00          	cmpl   $0x0,-0x2c(%ebp)
  80086b:	0f 85 75 ff ff ff    	jne    8007e6 <umain+0x13e>
		if (debug)
  800871:	83 3d 00 50 80 00 00 	cmpl   $0x0,0x805000
  800878:	0f 85 7b ff ff ff    	jne    8007f9 <umain+0x151>
		if ((r = fork()) < 0)
  80087e:	e8 5a 11 00 00       	call   8019dd <fork>
  800883:	89 c6                	mov    %eax,%esi
  800885:	85 c0                	test   %eax,%eax
  800887:	78 82                	js     80080b <umain+0x163>
		if (debug)
  800889:	83 3d 00 50 80 00 00 	cmpl   $0x0,0x805000
  800890:	75 8e                	jne    800820 <umain+0x178>
		if (r == 0) {
  800892:	85 f6                	test   %esi,%esi
  800894:	75 9d                	jne    800833 <umain+0x18b>
			runcmd(buf);
  800896:	83 ec 0c             	sub    $0xc,%esp
  800899:	53                   	push   %ebx
  80089a:	e8 63 f9 ff ff       	call   800202 <runcmd>
			exit();
  80089f:	e8 ee 01 00 00       	call   800a92 <exit>
  8008a4:	83 c4 10             	add    $0x10,%esp
  8008a7:	eb 96                	jmp    80083f <umain+0x197>

008008a9 <devcons_close>:
	return tot;
}

static int
devcons_close(struct Fd *fd)
{
  8008a9:	f3 0f 1e fb          	endbr32 
	USED(fd);

	return 0;
}
  8008ad:	b8 00 00 00 00       	mov    $0x0,%eax
  8008b2:	c3                   	ret    

008008b3 <devcons_stat>:

static int
devcons_stat(struct Fd *fd, struct Stat *stat)
{
  8008b3:	f3 0f 1e fb          	endbr32 
  8008b7:	55                   	push   %ebp
  8008b8:	89 e5                	mov    %esp,%ebp
  8008ba:	83 ec 10             	sub    $0x10,%esp
	strcpy(stat->st_name, "<cons>");
  8008bd:	68 09 37 80 00       	push   $0x803709
  8008c2:	ff 75 0c             	pushl  0xc(%ebp)
  8008c5:	e8 9a 09 00 00       	call   801264 <strcpy>
	return 0;
}
  8008ca:	b8 00 00 00 00       	mov    $0x0,%eax
  8008cf:	c9                   	leave  
  8008d0:	c3                   	ret    

008008d1 <devcons_write>:
{
  8008d1:	f3 0f 1e fb          	endbr32 
  8008d5:	55                   	push   %ebp
  8008d6:	89 e5                	mov    %esp,%ebp
  8008d8:	57                   	push   %edi
  8008d9:	56                   	push   %esi
  8008da:	53                   	push   %ebx
  8008db:	81 ec 8c 00 00 00    	sub    $0x8c,%esp
	for (tot = 0; tot < n; tot += m) {
  8008e1:	be 00 00 00 00       	mov    $0x0,%esi
		memmove(buf, (char*)vbuf + tot, m);
  8008e6:	8d bd 68 ff ff ff    	lea    -0x98(%ebp),%edi
	for (tot = 0; tot < n; tot += m) {
  8008ec:	3b 75 10             	cmp    0x10(%ebp),%esi
  8008ef:	73 31                	jae    800922 <devcons_write+0x51>
		m = n - tot;
  8008f1:	8b 5d 10             	mov    0x10(%ebp),%ebx
  8008f4:	29 f3                	sub    %esi,%ebx
  8008f6:	83 fb 7f             	cmp    $0x7f,%ebx
  8008f9:	b8 7f 00 00 00       	mov    $0x7f,%eax
  8008fe:	0f 47 d8             	cmova  %eax,%ebx
		memmove(buf, (char*)vbuf + tot, m);
  800901:	83 ec 04             	sub    $0x4,%esp
  800904:	53                   	push   %ebx
  800905:	89 f0                	mov    %esi,%eax
  800907:	03 45 0c             	add    0xc(%ebp),%eax
  80090a:	50                   	push   %eax
  80090b:	57                   	push   %edi
  80090c:	e8 09 0b 00 00       	call   80141a <memmove>
		sys_cputs(buf, m);
  800911:	83 c4 08             	add    $0x8,%esp
  800914:	53                   	push   %ebx
  800915:	57                   	push   %edi
  800916:	e8 bb 0c 00 00       	call   8015d6 <sys_cputs>
	for (tot = 0; tot < n; tot += m) {
  80091b:	01 de                	add    %ebx,%esi
  80091d:	83 c4 10             	add    $0x10,%esp
  800920:	eb ca                	jmp    8008ec <devcons_write+0x1b>
}
  800922:	89 f0                	mov    %esi,%eax
  800924:	8d 65 f4             	lea    -0xc(%ebp),%esp
  800927:	5b                   	pop    %ebx
  800928:	5e                   	pop    %esi
  800929:	5f                   	pop    %edi
  80092a:	5d                   	pop    %ebp
  80092b:	c3                   	ret    

0080092c <devcons_read>:
{
  80092c:	f3 0f 1e fb          	endbr32 
  800930:	55                   	push   %ebp
  800931:	89 e5                	mov    %esp,%ebp
  800933:	83 ec 08             	sub    $0x8,%esp
  800936:	b8 00 00 00 00       	mov    $0x0,%eax
	if (n == 0)
  80093b:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  80093f:	74 21                	je     800962 <devcons_read+0x36>
	while ((c = sys_cgetc()) == 0)
  800941:	e8 b2 0c 00 00       	call   8015f8 <sys_cgetc>
  800946:	85 c0                	test   %eax,%eax
  800948:	75 07                	jne    800951 <devcons_read+0x25>
		sys_yield();
  80094a:	e8 34 0d 00 00       	call   801683 <sys_yield>
  80094f:	eb f0                	jmp    800941 <devcons_read+0x15>
	if (c < 0)
  800951:	78 0f                	js     800962 <devcons_read+0x36>
	if (c == 0x04)	// ctl-d is eof
  800953:	83 f8 04             	cmp    $0x4,%eax
  800956:	74 0c                	je     800964 <devcons_read+0x38>
	*(char*)vbuf = c;
  800958:	8b 55 0c             	mov    0xc(%ebp),%edx
  80095b:	88 02                	mov    %al,(%edx)
	return 1;
  80095d:	b8 01 00 00 00       	mov    $0x1,%eax
}
  800962:	c9                   	leave  
  800963:	c3                   	ret    
		return 0;
  800964:	b8 00 00 00 00       	mov    $0x0,%eax
  800969:	eb f7                	jmp    800962 <devcons_read+0x36>

0080096b <cputchar>:
{
  80096b:	f3 0f 1e fb          	endbr32 
  80096f:	55                   	push   %ebp
  800970:	89 e5                	mov    %esp,%ebp
  800972:	83 ec 20             	sub    $0x20,%esp
	char c = ch;
  800975:	8b 45 08             	mov    0x8(%ebp),%eax
  800978:	88 45 f7             	mov    %al,-0x9(%ebp)
	sys_cputs(&c, 1);
  80097b:	6a 01                	push   $0x1
  80097d:	8d 45 f7             	lea    -0x9(%ebp),%eax
  800980:	50                   	push   %eax
  800981:	e8 50 0c 00 00       	call   8015d6 <sys_cputs>
}
  800986:	83 c4 10             	add    $0x10,%esp
  800989:	c9                   	leave  
  80098a:	c3                   	ret    

0080098b <getchar>:
{
  80098b:	f3 0f 1e fb          	endbr32 
  80098f:	55                   	push   %ebp
  800990:	89 e5                	mov    %esp,%ebp
  800992:	83 ec 1c             	sub    $0x1c,%esp
	r = read(0, &c, 1);
  800995:	6a 01                	push   $0x1
  800997:	8d 45 f7             	lea    -0x9(%ebp),%eax
  80099a:	50                   	push   %eax
  80099b:	6a 00                	push   $0x0
  80099d:	e8 bd 16 00 00       	call   80205f <read>
	if (r < 0)
  8009a2:	83 c4 10             	add    $0x10,%esp
  8009a5:	85 c0                	test   %eax,%eax
  8009a7:	78 06                	js     8009af <getchar+0x24>
	if (r < 1)
  8009a9:	74 06                	je     8009b1 <getchar+0x26>
	return c;
  8009ab:	0f b6 45 f7          	movzbl -0x9(%ebp),%eax
}
  8009af:	c9                   	leave  
  8009b0:	c3                   	ret    
		return -E_EOF;
  8009b1:	b8 f8 ff ff ff       	mov    $0xfffffff8,%eax
  8009b6:	eb f7                	jmp    8009af <getchar+0x24>

008009b8 <iscons>:
{
  8009b8:	f3 0f 1e fb          	endbr32 
  8009bc:	55                   	push   %ebp
  8009bd:	89 e5                	mov    %esp,%ebp
  8009bf:	83 ec 20             	sub    $0x20,%esp
	if ((r = fd_lookup(fdnum, &fd)) < 0)
  8009c2:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8009c5:	50                   	push   %eax
  8009c6:	ff 75 08             	pushl  0x8(%ebp)
  8009c9:	e8 0e 14 00 00       	call   801ddc <fd_lookup>
  8009ce:	83 c4 10             	add    $0x10,%esp
  8009d1:	85 c0                	test   %eax,%eax
  8009d3:	78 11                	js     8009e6 <iscons+0x2e>
	return fd->fd_dev_id == devcons.dev_id;
  8009d5:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8009d8:	8b 15 00 40 80 00    	mov    0x804000,%edx
  8009de:	39 10                	cmp    %edx,(%eax)
  8009e0:	0f 94 c0             	sete   %al
  8009e3:	0f b6 c0             	movzbl %al,%eax
}
  8009e6:	c9                   	leave  
  8009e7:	c3                   	ret    

008009e8 <opencons>:
{
  8009e8:	f3 0f 1e fb          	endbr32 
  8009ec:	55                   	push   %ebp
  8009ed:	89 e5                	mov    %esp,%ebp
  8009ef:	83 ec 24             	sub    $0x24,%esp
	if ((r = fd_alloc(&fd)) < 0)
  8009f2:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8009f5:	50                   	push   %eax
  8009f6:	e8 8b 13 00 00       	call   801d86 <fd_alloc>
  8009fb:	83 c4 10             	add    $0x10,%esp
  8009fe:	85 c0                	test   %eax,%eax
  800a00:	78 3a                	js     800a3c <opencons+0x54>
	if ((r = sys_page_alloc(0, fd, PTE_P|PTE_U|PTE_W|PTE_SHARE)) < 0)
  800a02:	83 ec 04             	sub    $0x4,%esp
  800a05:	68 07 04 00 00       	push   $0x407
  800a0a:	ff 75 f4             	pushl  -0xc(%ebp)
  800a0d:	6a 00                	push   $0x0
  800a0f:	e8 92 0c 00 00       	call   8016a6 <sys_page_alloc>
  800a14:	83 c4 10             	add    $0x10,%esp
  800a17:	85 c0                	test   %eax,%eax
  800a19:	78 21                	js     800a3c <opencons+0x54>
	fd->fd_dev_id = devcons.dev_id;
  800a1b:	8b 45 f4             	mov    -0xc(%ebp),%eax
  800a1e:	8b 15 00 40 80 00    	mov    0x804000,%edx
  800a24:	89 10                	mov    %edx,(%eax)
	fd->fd_omode = O_RDWR;
  800a26:	8b 45 f4             	mov    -0xc(%ebp),%eax
  800a29:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	return fd2num(fd);
  800a30:	83 ec 0c             	sub    $0xc,%esp
  800a33:	50                   	push   %eax
  800a34:	e8 1e 13 00 00       	call   801d57 <fd2num>
  800a39:	83 c4 10             	add    $0x10,%esp
}
  800a3c:	c9                   	leave  
  800a3d:	c3                   	ret    

00800a3e <libmain>:
const volatile struct Env *thisenv;
const char *binaryname = "<unknown>";

void
libmain(int argc, char **argv)
{
  800a3e:	f3 0f 1e fb          	endbr32 
  800a42:	55                   	push   %ebp
  800a43:	89 e5                	mov    %esp,%ebp
  800a45:	56                   	push   %esi
  800a46:	53                   	push   %ebx
  800a47:	8b 5d 08             	mov    0x8(%ebp),%ebx
  800a4a:	8b 75 0c             	mov    0xc(%ebp),%esi
	;    //系统调用，我们已经在Exercise 7中实现了
	
	
	
	//屏幕上打印出来了字母，但后续报错了，有意思，让我看看问题出现在哪。
	thisenv=0;
  800a4d:	c7 05 24 54 80 00 00 	movl   $0x0,0x805424
  800a54:	00 00 00 
	thisenv = &envs[ENVX(sys_getenvid())];      //获取Env结构指针
  800a57:	e8 04 0c 00 00       	call   801660 <sys_getenvid>
  800a5c:	25 ff 03 00 00       	and    $0x3ff,%eax
  800a61:	6b c0 7c             	imul   $0x7c,%eax,%eax
  800a64:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  800a69:	a3 24 54 80 00       	mov    %eax,0x805424

	// save the name of the program so that panic() can use it
	if (argc > 0)
  800a6e:	85 db                	test   %ebx,%ebx
  800a70:	7e 07                	jle    800a79 <libmain+0x3b>
		binaryname = argv[0];
  800a72:	8b 06                	mov    (%esi),%eax
  800a74:	a3 1c 40 80 00       	mov    %eax,0x80401c

	// call user main routine
	umain(argc, argv);
  800a79:	83 ec 08             	sub    $0x8,%esp
  800a7c:	56                   	push   %esi
  800a7d:	53                   	push   %ebx
  800a7e:	e8 25 fc ff ff       	call   8006a8 <umain>

	// exit gracefully
	exit();
  800a83:	e8 0a 00 00 00       	call   800a92 <exit>
}
  800a88:	83 c4 10             	add    $0x10,%esp
  800a8b:	8d 65 f8             	lea    -0x8(%ebp),%esp
  800a8e:	5b                   	pop    %ebx
  800a8f:	5e                   	pop    %esi
  800a90:	5d                   	pop    %ebp
  800a91:	c3                   	ret    

00800a92 <exit>:

#include <inc/lib.h>

void
exit(void)
{
  800a92:	f3 0f 1e fb          	endbr32 
  800a96:	55                   	push   %ebp
  800a97:	89 e5                	mov    %esp,%ebp
  800a99:	83 ec 08             	sub    $0x8,%esp
	close_all();
  800a9c:	e8 a5 14 00 00       	call   801f46 <close_all>
	sys_env_destroy(0);
  800aa1:	83 ec 0c             	sub    $0xc,%esp
  800aa4:	6a 00                	push   $0x0
  800aa6:	e8 70 0b 00 00       	call   80161b <sys_env_destroy>
}
  800aab:	83 c4 10             	add    $0x10,%esp
  800aae:	c9                   	leave  
  800aaf:	c3                   	ret    

00800ab0 <_panic>:
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt, ...)
{
  800ab0:	f3 0f 1e fb          	endbr32 
  800ab4:	55                   	push   %ebp
  800ab5:	89 e5                	mov    %esp,%ebp
  800ab7:	56                   	push   %esi
  800ab8:	53                   	push   %ebx
	va_list ap;

	va_start(ap, fmt);
  800ab9:	8d 5d 14             	lea    0x14(%ebp),%ebx

	// Print the panic message
	cprintf("[%08x] user panic in %s at %s:%d: ",
  800abc:	8b 35 1c 40 80 00    	mov    0x80401c,%esi
  800ac2:	e8 99 0b 00 00       	call   801660 <sys_getenvid>
  800ac7:	83 ec 0c             	sub    $0xc,%esp
  800aca:	ff 75 0c             	pushl  0xc(%ebp)
  800acd:	ff 75 08             	pushl  0x8(%ebp)
  800ad0:	56                   	push   %esi
  800ad1:	50                   	push   %eax
  800ad2:	68 20 37 80 00       	push   $0x803720
  800ad7:	e8 bb 00 00 00       	call   800b97 <cprintf>
		sys_getenvid(), binaryname, file, line);
	vcprintf(fmt, ap);
  800adc:	83 c4 18             	add    $0x18,%esp
  800adf:	53                   	push   %ebx
  800ae0:	ff 75 10             	pushl  0x10(%ebp)
  800ae3:	e8 5a 00 00 00       	call   800b42 <vcprintf>
	cprintf("\n");
  800ae8:	c7 04 24 20 35 80 00 	movl   $0x803520,(%esp)
  800aef:	e8 a3 00 00 00       	call   800b97 <cprintf>
  800af4:	83 c4 10             	add    $0x10,%esp

	// Cause a breakpoint exception
	while (1)
		asm volatile("int3");
  800af7:	cc                   	int3   
  800af8:	eb fd                	jmp    800af7 <_panic+0x47>

00800afa <putch>:
};


static void
putch(int ch, struct printbuf *b)
{
  800afa:	f3 0f 1e fb          	endbr32 
  800afe:	55                   	push   %ebp
  800aff:	89 e5                	mov    %esp,%ebp
  800b01:	53                   	push   %ebx
  800b02:	83 ec 04             	sub    $0x4,%esp
  800b05:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	b->buf[b->idx++] = ch;
  800b08:	8b 13                	mov    (%ebx),%edx
  800b0a:	8d 42 01             	lea    0x1(%edx),%eax
  800b0d:	89 03                	mov    %eax,(%ebx)
  800b0f:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800b12:	88 4c 13 08          	mov    %cl,0x8(%ebx,%edx,1)
	if (b->idx == 256-1) {
  800b16:	3d ff 00 00 00       	cmp    $0xff,%eax
  800b1b:	74 09                	je     800b26 <putch+0x2c>
		sys_cputs(b->buf, b->idx);
		b->idx = 0;
	}
	b->cnt++;
  800b1d:	83 43 04 01          	addl   $0x1,0x4(%ebx)
}
  800b21:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  800b24:	c9                   	leave  
  800b25:	c3                   	ret    
		sys_cputs(b->buf, b->idx);
  800b26:	83 ec 08             	sub    $0x8,%esp
  800b29:	68 ff 00 00 00       	push   $0xff
  800b2e:	8d 43 08             	lea    0x8(%ebx),%eax
  800b31:	50                   	push   %eax
  800b32:	e8 9f 0a 00 00       	call   8015d6 <sys_cputs>
		b->idx = 0;
  800b37:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
  800b3d:	83 c4 10             	add    $0x10,%esp
  800b40:	eb db                	jmp    800b1d <putch+0x23>

00800b42 <vcprintf>:

int
vcprintf(const char *fmt, va_list ap)
{
  800b42:	f3 0f 1e fb          	endbr32 
  800b46:	55                   	push   %ebp
  800b47:	89 e5                	mov    %esp,%ebp
  800b49:	81 ec 18 01 00 00    	sub    $0x118,%esp
	struct printbuf b;

	b.idx = 0;
  800b4f:	c7 85 f0 fe ff ff 00 	movl   $0x0,-0x110(%ebp)
  800b56:	00 00 00 
	b.cnt = 0;
  800b59:	c7 85 f4 fe ff ff 00 	movl   $0x0,-0x10c(%ebp)
  800b60:	00 00 00 
	vprintfmt((void*)putch, &b, fmt, ap);
  800b63:	ff 75 0c             	pushl  0xc(%ebp)
  800b66:	ff 75 08             	pushl  0x8(%ebp)
  800b69:	8d 85 f0 fe ff ff    	lea    -0x110(%ebp),%eax
  800b6f:	50                   	push   %eax
  800b70:	68 fa 0a 80 00       	push   $0x800afa
  800b75:	e8 20 01 00 00       	call   800c9a <vprintfmt>
	sys_cputs(b.buf, b.idx);
  800b7a:	83 c4 08             	add    $0x8,%esp
  800b7d:	ff b5 f0 fe ff ff    	pushl  -0x110(%ebp)
  800b83:	8d 85 f8 fe ff ff    	lea    -0x108(%ebp),%eax
  800b89:	50                   	push   %eax
  800b8a:	e8 47 0a 00 00       	call   8015d6 <sys_cputs>

	return b.cnt;
}
  800b8f:	8b 85 f4 fe ff ff    	mov    -0x10c(%ebp),%eax
  800b95:	c9                   	leave  
  800b96:	c3                   	ret    

00800b97 <cprintf>:

int
cprintf(const char *fmt, ...)
{
  800b97:	f3 0f 1e fb          	endbr32 
  800b9b:	55                   	push   %ebp
  800b9c:	89 e5                	mov    %esp,%ebp
  800b9e:	83 ec 10             	sub    $0x10,%esp
	va_list ap;
	int cnt;

	va_start(ap, fmt);
  800ba1:	8d 45 0c             	lea    0xc(%ebp),%eax
	cnt = vcprintf(fmt, ap);
  800ba4:	50                   	push   %eax
  800ba5:	ff 75 08             	pushl  0x8(%ebp)
  800ba8:	e8 95 ff ff ff       	call   800b42 <vcprintf>
	va_end(ap);

	return cnt;
}
  800bad:	c9                   	leave  
  800bae:	c3                   	ret    

00800baf <printnum>:
 * using specified putch function and associated pointer putdat.
 */
static void
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
  800baf:	55                   	push   %ebp
  800bb0:	89 e5                	mov    %esp,%ebp
  800bb2:	57                   	push   %edi
  800bb3:	56                   	push   %esi
  800bb4:	53                   	push   %ebx
  800bb5:	83 ec 1c             	sub    $0x1c,%esp
  800bb8:	89 c7                	mov    %eax,%edi
  800bba:	89 d6                	mov    %edx,%esi
  800bbc:	8b 45 08             	mov    0x8(%ebp),%eax
  800bbf:	8b 55 0c             	mov    0xc(%ebp),%edx
  800bc2:	89 d1                	mov    %edx,%ecx
  800bc4:	89 c2                	mov    %eax,%edx
  800bc6:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800bc9:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  800bcc:	8b 45 10             	mov    0x10(%ebp),%eax
  800bcf:	8b 5d 14             	mov    0x14(%ebp),%ebx
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
  800bd2:	89 45 e0             	mov    %eax,-0x20(%ebp)
  800bd5:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
  800bdc:	39 c2                	cmp    %eax,%edx
  800bde:	1b 4d e4             	sbb    -0x1c(%ebp),%ecx
  800be1:	72 3e                	jb     800c21 <printnum+0x72>
		printnum(putch, putdat, num / base, base, width - 1, padc);
  800be3:	83 ec 0c             	sub    $0xc,%esp
  800be6:	ff 75 18             	pushl  0x18(%ebp)
  800be9:	83 eb 01             	sub    $0x1,%ebx
  800bec:	53                   	push   %ebx
  800bed:	50                   	push   %eax
  800bee:	83 ec 08             	sub    $0x8,%esp
  800bf1:	ff 75 e4             	pushl  -0x1c(%ebp)
  800bf4:	ff 75 e0             	pushl  -0x20(%ebp)
  800bf7:	ff 75 dc             	pushl  -0x24(%ebp)
  800bfa:	ff 75 d8             	pushl  -0x28(%ebp)
  800bfd:	e8 8e 26 00 00       	call   803290 <__udivdi3>
  800c02:	83 c4 18             	add    $0x18,%esp
  800c05:	52                   	push   %edx
  800c06:	50                   	push   %eax
  800c07:	89 f2                	mov    %esi,%edx
  800c09:	89 f8                	mov    %edi,%eax
  800c0b:	e8 9f ff ff ff       	call   800baf <printnum>
  800c10:	83 c4 20             	add    $0x20,%esp
  800c13:	eb 13                	jmp    800c28 <printnum+0x79>
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
			putch(padc, putdat);
  800c15:	83 ec 08             	sub    $0x8,%esp
  800c18:	56                   	push   %esi
  800c19:	ff 75 18             	pushl  0x18(%ebp)
  800c1c:	ff d7                	call   *%edi
  800c1e:	83 c4 10             	add    $0x10,%esp
		while (--width > 0)
  800c21:	83 eb 01             	sub    $0x1,%ebx
  800c24:	85 db                	test   %ebx,%ebx
  800c26:	7f ed                	jg     800c15 <printnum+0x66>
	}

	// then print this (the least significant) digit
	putch("0123456789abcdef"[num % base], putdat);
  800c28:	83 ec 08             	sub    $0x8,%esp
  800c2b:	56                   	push   %esi
  800c2c:	83 ec 04             	sub    $0x4,%esp
  800c2f:	ff 75 e4             	pushl  -0x1c(%ebp)
  800c32:	ff 75 e0             	pushl  -0x20(%ebp)
  800c35:	ff 75 dc             	pushl  -0x24(%ebp)
  800c38:	ff 75 d8             	pushl  -0x28(%ebp)
  800c3b:	e8 60 27 00 00       	call   8033a0 <__umoddi3>
  800c40:	83 c4 14             	add    $0x14,%esp
  800c43:	0f be 80 43 37 80 00 	movsbl 0x803743(%eax),%eax
  800c4a:	50                   	push   %eax
  800c4b:	ff d7                	call   *%edi
}
  800c4d:	83 c4 10             	add    $0x10,%esp
  800c50:	8d 65 f4             	lea    -0xc(%ebp),%esp
  800c53:	5b                   	pop    %ebx
  800c54:	5e                   	pop    %esi
  800c55:	5f                   	pop    %edi
  800c56:	5d                   	pop    %ebp
  800c57:	c3                   	ret    

00800c58 <sprintputch>:
	int cnt;
};

static void
sprintputch(int ch, struct sprintbuf *b)
{
  800c58:	f3 0f 1e fb          	endbr32 
  800c5c:	55                   	push   %ebp
  800c5d:	89 e5                	mov    %esp,%ebp
  800c5f:	8b 45 0c             	mov    0xc(%ebp),%eax
	b->cnt++;
  800c62:	83 40 08 01          	addl   $0x1,0x8(%eax)
	if (b->buf < b->ebuf)
  800c66:	8b 10                	mov    (%eax),%edx
  800c68:	3b 50 04             	cmp    0x4(%eax),%edx
  800c6b:	73 0a                	jae    800c77 <sprintputch+0x1f>
		*b->buf++ = ch;
  800c6d:	8d 4a 01             	lea    0x1(%edx),%ecx
  800c70:	89 08                	mov    %ecx,(%eax)
  800c72:	8b 45 08             	mov    0x8(%ebp),%eax
  800c75:	88 02                	mov    %al,(%edx)
}
  800c77:	5d                   	pop    %ebp
  800c78:	c3                   	ret    

00800c79 <printfmt>:
{
  800c79:	f3 0f 1e fb          	endbr32 
  800c7d:	55                   	push   %ebp
  800c7e:	89 e5                	mov    %esp,%ebp
  800c80:	83 ec 08             	sub    $0x8,%esp
	va_start(ap, fmt);
  800c83:	8d 45 14             	lea    0x14(%ebp),%eax
	vprintfmt(putch, putdat, fmt, ap);
  800c86:	50                   	push   %eax
  800c87:	ff 75 10             	pushl  0x10(%ebp)
  800c8a:	ff 75 0c             	pushl  0xc(%ebp)
  800c8d:	ff 75 08             	pushl  0x8(%ebp)
  800c90:	e8 05 00 00 00       	call   800c9a <vprintfmt>
}
  800c95:	83 c4 10             	add    $0x10,%esp
  800c98:	c9                   	leave  
  800c99:	c3                   	ret    

00800c9a <vprintfmt>:
{
  800c9a:	f3 0f 1e fb          	endbr32 
  800c9e:	55                   	push   %ebp
  800c9f:	89 e5                	mov    %esp,%ebp
  800ca1:	57                   	push   %edi
  800ca2:	56                   	push   %esi
  800ca3:	53                   	push   %ebx
  800ca4:	83 ec 3c             	sub    $0x3c,%esp
  800ca7:	8b 75 08             	mov    0x8(%ebp),%esi
  800caa:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  800cad:	8b 7d 10             	mov    0x10(%ebp),%edi
  800cb0:	e9 5d 03 00 00       	jmp    801012 <vprintfmt+0x378>
		padc = ' ';
  800cb5:	c6 45 d3 20          	movb   $0x20,-0x2d(%ebp)
		altflag = 0;
  800cb9:	c7 45 e0 00 00 00 00 	movl   $0x0,-0x20(%ebp)
		precision = -1;
  800cc0:	c7 45 d8 ff ff ff ff 	movl   $0xffffffff,-0x28(%ebp)
		width = -1;
  800cc7:	c7 45 d4 ff ff ff ff 	movl   $0xffffffff,-0x2c(%ebp)
		lflag = 0;
  800cce:	b9 00 00 00 00       	mov    $0x0,%ecx
		switch (ch = *(unsigned char *) fmt++) {
  800cd3:	8d 47 01             	lea    0x1(%edi),%eax
  800cd6:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  800cd9:	0f b6 17             	movzbl (%edi),%edx
  800cdc:	8d 42 dd             	lea    -0x23(%edx),%eax
  800cdf:	3c 55                	cmp    $0x55,%al
  800ce1:	0f 87 ae 03 00 00    	ja     801095 <vprintfmt+0x3fb>
  800ce7:	0f b6 c0             	movzbl %al,%eax
  800cea:	3e ff 24 85 80 38 80 	notrack jmp *0x803880(,%eax,4)
  800cf1:	00 
  800cf2:	8b 7d e4             	mov    -0x1c(%ebp),%edi
			padc = '-';
  800cf5:	c6 45 d3 2d          	movb   $0x2d,-0x2d(%ebp)
  800cf9:	eb d8                	jmp    800cd3 <vprintfmt+0x39>
		switch (ch = *(unsigned char *) fmt++) {
  800cfb:	8b 7d e4             	mov    -0x1c(%ebp),%edi
  800cfe:	c6 45 d3 30          	movb   $0x30,-0x2d(%ebp)
  800d02:	eb cf                	jmp    800cd3 <vprintfmt+0x39>
  800d04:	0f b6 d2             	movzbl %dl,%edx
  800d07:	8b 7d e4             	mov    -0x1c(%ebp),%edi
			for (precision = 0; ; ++fmt) {
  800d0a:	b8 00 00 00 00       	mov    $0x0,%eax
  800d0f:	89 4d e4             	mov    %ecx,-0x1c(%ebp)
				precision = precision * 10 + ch - '0';
  800d12:	8d 04 80             	lea    (%eax,%eax,4),%eax
  800d15:	8d 44 42 d0          	lea    -0x30(%edx,%eax,2),%eax
				ch = *fmt;
  800d19:	0f be 17             	movsbl (%edi),%edx
				if (ch < '0' || ch > '9')
  800d1c:	8d 4a d0             	lea    -0x30(%edx),%ecx
  800d1f:	83 f9 09             	cmp    $0x9,%ecx
  800d22:	77 55                	ja     800d79 <vprintfmt+0xdf>
			for (precision = 0; ; ++fmt) {
  800d24:	83 c7 01             	add    $0x1,%edi
				precision = precision * 10 + ch - '0';
  800d27:	eb e9                	jmp    800d12 <vprintfmt+0x78>
			precision = va_arg(ap, int);
  800d29:	8b 45 14             	mov    0x14(%ebp),%eax
  800d2c:	8b 00                	mov    (%eax),%eax
  800d2e:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800d31:	8b 45 14             	mov    0x14(%ebp),%eax
  800d34:	8d 40 04             	lea    0x4(%eax),%eax
  800d37:	89 45 14             	mov    %eax,0x14(%ebp)
		switch (ch = *(unsigned char *) fmt++) {
  800d3a:	8b 7d e4             	mov    -0x1c(%ebp),%edi
			if (width < 0)
  800d3d:	83 7d d4 00          	cmpl   $0x0,-0x2c(%ebp)
  800d41:	79 90                	jns    800cd3 <vprintfmt+0x39>
				width = precision, precision = -1;
  800d43:	8b 45 d8             	mov    -0x28(%ebp),%eax
  800d46:	89 45 d4             	mov    %eax,-0x2c(%ebp)
  800d49:	c7 45 d8 ff ff ff ff 	movl   $0xffffffff,-0x28(%ebp)
  800d50:	eb 81                	jmp    800cd3 <vprintfmt+0x39>
  800d52:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  800d55:	85 c0                	test   %eax,%eax
  800d57:	ba 00 00 00 00       	mov    $0x0,%edx
  800d5c:	0f 49 d0             	cmovns %eax,%edx
  800d5f:	89 55 d4             	mov    %edx,-0x2c(%ebp)
		switch (ch = *(unsigned char *) fmt++) {
  800d62:	8b 7d e4             	mov    -0x1c(%ebp),%edi
			goto reswitch;
  800d65:	e9 69 ff ff ff       	jmp    800cd3 <vprintfmt+0x39>
		switch (ch = *(unsigned char *) fmt++) {
  800d6a:	8b 7d e4             	mov    -0x1c(%ebp),%edi
			altflag = 1;
  800d6d:	c7 45 e0 01 00 00 00 	movl   $0x1,-0x20(%ebp)
			goto reswitch;
  800d74:	e9 5a ff ff ff       	jmp    800cd3 <vprintfmt+0x39>
  800d79:	8b 4d e4             	mov    -0x1c(%ebp),%ecx
  800d7c:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800d7f:	eb bc                	jmp    800d3d <vprintfmt+0xa3>
			lflag++;
  800d81:	83 c1 01             	add    $0x1,%ecx
		switch (ch = *(unsigned char *) fmt++) {
  800d84:	8b 7d e4             	mov    -0x1c(%ebp),%edi
			goto reswitch;
  800d87:	e9 47 ff ff ff       	jmp    800cd3 <vprintfmt+0x39>
			putch(va_arg(ap, int), putdat);
  800d8c:	8b 45 14             	mov    0x14(%ebp),%eax
  800d8f:	8d 78 04             	lea    0x4(%eax),%edi
  800d92:	83 ec 08             	sub    $0x8,%esp
  800d95:	53                   	push   %ebx
  800d96:	ff 30                	pushl  (%eax)
  800d98:	ff d6                	call   *%esi
			break;
  800d9a:	83 c4 10             	add    $0x10,%esp
			putch(va_arg(ap, int), putdat);
  800d9d:	89 7d 14             	mov    %edi,0x14(%ebp)
			break;
  800da0:	e9 6a 02 00 00       	jmp    80100f <vprintfmt+0x375>
			err = va_arg(ap, int);
  800da5:	8b 45 14             	mov    0x14(%ebp),%eax
  800da8:	8d 78 04             	lea    0x4(%eax),%edi
  800dab:	8b 00                	mov    (%eax),%eax
  800dad:	99                   	cltd   
  800dae:	31 d0                	xor    %edx,%eax
  800db0:	29 d0                	sub    %edx,%eax
			if (err >= MAXERROR || (p = error_string[err]) == NULL)
  800db2:	83 f8 0f             	cmp    $0xf,%eax
  800db5:	7f 23                	jg     800dda <vprintfmt+0x140>
  800db7:	8b 14 85 e0 39 80 00 	mov    0x8039e0(,%eax,4),%edx
  800dbe:	85 d2                	test   %edx,%edx
  800dc0:	74 18                	je     800dda <vprintfmt+0x140>
				printfmt(putch, putdat, "%s", p);
  800dc2:	52                   	push   %edx
  800dc3:	68 61 36 80 00       	push   $0x803661
  800dc8:	53                   	push   %ebx
  800dc9:	56                   	push   %esi
  800dca:	e8 aa fe ff ff       	call   800c79 <printfmt>
  800dcf:	83 c4 10             	add    $0x10,%esp
			err = va_arg(ap, int);
  800dd2:	89 7d 14             	mov    %edi,0x14(%ebp)
  800dd5:	e9 35 02 00 00       	jmp    80100f <vprintfmt+0x375>
				printfmt(putch, putdat, "error %d", err);
  800dda:	50                   	push   %eax
  800ddb:	68 5b 37 80 00       	push   $0x80375b
  800de0:	53                   	push   %ebx
  800de1:	56                   	push   %esi
  800de2:	e8 92 fe ff ff       	call   800c79 <printfmt>
  800de7:	83 c4 10             	add    $0x10,%esp
			err = va_arg(ap, int);
  800dea:	89 7d 14             	mov    %edi,0x14(%ebp)
				printfmt(putch, putdat, "error %d", err);
  800ded:	e9 1d 02 00 00       	jmp    80100f <vprintfmt+0x375>
			if ((p = va_arg(ap, char *)) == NULL)
  800df2:	8b 45 14             	mov    0x14(%ebp),%eax
  800df5:	83 c0 04             	add    $0x4,%eax
  800df8:	89 45 c8             	mov    %eax,-0x38(%ebp)
  800dfb:	8b 45 14             	mov    0x14(%ebp),%eax
  800dfe:	8b 10                	mov    (%eax),%edx
				p = "(null)";
  800e00:	85 d2                	test   %edx,%edx
  800e02:	b8 54 37 80 00       	mov    $0x803754,%eax
  800e07:	0f 45 c2             	cmovne %edx,%eax
  800e0a:	89 45 cc             	mov    %eax,-0x34(%ebp)
			if (width > 0 && padc != '-')
  800e0d:	83 7d d4 00          	cmpl   $0x0,-0x2c(%ebp)
  800e11:	7e 06                	jle    800e19 <vprintfmt+0x17f>
  800e13:	80 7d d3 2d          	cmpb   $0x2d,-0x2d(%ebp)
  800e17:	75 0d                	jne    800e26 <vprintfmt+0x18c>
				for (width -= strnlen(p, precision); width > 0; width--)
  800e19:	8b 45 cc             	mov    -0x34(%ebp),%eax
  800e1c:	89 c7                	mov    %eax,%edi
  800e1e:	03 45 d4             	add    -0x2c(%ebp),%eax
  800e21:	89 45 d4             	mov    %eax,-0x2c(%ebp)
  800e24:	eb 55                	jmp    800e7b <vprintfmt+0x1e1>
  800e26:	83 ec 08             	sub    $0x8,%esp
  800e29:	ff 75 d8             	pushl  -0x28(%ebp)
  800e2c:	ff 75 cc             	pushl  -0x34(%ebp)
  800e2f:	e8 09 04 00 00       	call   80123d <strnlen>
  800e34:	8b 55 d4             	mov    -0x2c(%ebp),%edx
  800e37:	29 c2                	sub    %eax,%edx
  800e39:	89 55 c4             	mov    %edx,-0x3c(%ebp)
  800e3c:	83 c4 10             	add    $0x10,%esp
  800e3f:	89 d7                	mov    %edx,%edi
					putch(padc, putdat);
  800e41:	0f be 45 d3          	movsbl -0x2d(%ebp),%eax
  800e45:	89 45 d4             	mov    %eax,-0x2c(%ebp)
				for (width -= strnlen(p, precision); width > 0; width--)
  800e48:	85 ff                	test   %edi,%edi
  800e4a:	7e 11                	jle    800e5d <vprintfmt+0x1c3>
					putch(padc, putdat);
  800e4c:	83 ec 08             	sub    $0x8,%esp
  800e4f:	53                   	push   %ebx
  800e50:	ff 75 d4             	pushl  -0x2c(%ebp)
  800e53:	ff d6                	call   *%esi
				for (width -= strnlen(p, precision); width > 0; width--)
  800e55:	83 ef 01             	sub    $0x1,%edi
  800e58:	83 c4 10             	add    $0x10,%esp
  800e5b:	eb eb                	jmp    800e48 <vprintfmt+0x1ae>
  800e5d:	8b 55 c4             	mov    -0x3c(%ebp),%edx
  800e60:	85 d2                	test   %edx,%edx
  800e62:	b8 00 00 00 00       	mov    $0x0,%eax
  800e67:	0f 49 c2             	cmovns %edx,%eax
  800e6a:	29 c2                	sub    %eax,%edx
  800e6c:	89 55 d4             	mov    %edx,-0x2c(%ebp)
  800e6f:	eb a8                	jmp    800e19 <vprintfmt+0x17f>
					putch(ch, putdat);
  800e71:	83 ec 08             	sub    $0x8,%esp
  800e74:	53                   	push   %ebx
  800e75:	52                   	push   %edx
  800e76:	ff d6                	call   *%esi
  800e78:	83 c4 10             	add    $0x10,%esp
  800e7b:	8b 4d d4             	mov    -0x2c(%ebp),%ecx
  800e7e:	29 f9                	sub    %edi,%ecx
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  800e80:	83 c7 01             	add    $0x1,%edi
  800e83:	0f b6 47 ff          	movzbl -0x1(%edi),%eax
  800e87:	0f be d0             	movsbl %al,%edx
  800e8a:	85 d2                	test   %edx,%edx
  800e8c:	74 4b                	je     800ed9 <vprintfmt+0x23f>
  800e8e:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  800e92:	78 06                	js     800e9a <vprintfmt+0x200>
  800e94:	83 6d d8 01          	subl   $0x1,-0x28(%ebp)
  800e98:	78 1e                	js     800eb8 <vprintfmt+0x21e>
				if (altflag && (ch < ' ' || ch > '~'))
  800e9a:	83 7d e0 00          	cmpl   $0x0,-0x20(%ebp)
  800e9e:	74 d1                	je     800e71 <vprintfmt+0x1d7>
  800ea0:	0f be c0             	movsbl %al,%eax
  800ea3:	83 e8 20             	sub    $0x20,%eax
  800ea6:	83 f8 5e             	cmp    $0x5e,%eax
  800ea9:	76 c6                	jbe    800e71 <vprintfmt+0x1d7>
					putch('?', putdat);
  800eab:	83 ec 08             	sub    $0x8,%esp
  800eae:	53                   	push   %ebx
  800eaf:	6a 3f                	push   $0x3f
  800eb1:	ff d6                	call   *%esi
  800eb3:	83 c4 10             	add    $0x10,%esp
  800eb6:	eb c3                	jmp    800e7b <vprintfmt+0x1e1>
  800eb8:	89 cf                	mov    %ecx,%edi
  800eba:	eb 0e                	jmp    800eca <vprintfmt+0x230>
				putch(' ', putdat);
  800ebc:	83 ec 08             	sub    $0x8,%esp
  800ebf:	53                   	push   %ebx
  800ec0:	6a 20                	push   $0x20
  800ec2:	ff d6                	call   *%esi
			for (; width > 0; width--)
  800ec4:	83 ef 01             	sub    $0x1,%edi
  800ec7:	83 c4 10             	add    $0x10,%esp
  800eca:	85 ff                	test   %edi,%edi
  800ecc:	7f ee                	jg     800ebc <vprintfmt+0x222>
			if ((p = va_arg(ap, char *)) == NULL)
  800ece:	8b 45 c8             	mov    -0x38(%ebp),%eax
  800ed1:	89 45 14             	mov    %eax,0x14(%ebp)
  800ed4:	e9 36 01 00 00       	jmp    80100f <vprintfmt+0x375>
  800ed9:	89 cf                	mov    %ecx,%edi
  800edb:	eb ed                	jmp    800eca <vprintfmt+0x230>
	if (lflag >= 2)
  800edd:	83 f9 01             	cmp    $0x1,%ecx
  800ee0:	7f 1f                	jg     800f01 <vprintfmt+0x267>
	else if (lflag)
  800ee2:	85 c9                	test   %ecx,%ecx
  800ee4:	74 67                	je     800f4d <vprintfmt+0x2b3>
		return va_arg(*ap, long);
  800ee6:	8b 45 14             	mov    0x14(%ebp),%eax
  800ee9:	8b 00                	mov    (%eax),%eax
  800eeb:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800eee:	89 c1                	mov    %eax,%ecx
  800ef0:	c1 f9 1f             	sar    $0x1f,%ecx
  800ef3:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  800ef6:	8b 45 14             	mov    0x14(%ebp),%eax
  800ef9:	8d 40 04             	lea    0x4(%eax),%eax
  800efc:	89 45 14             	mov    %eax,0x14(%ebp)
  800eff:	eb 17                	jmp    800f18 <vprintfmt+0x27e>
		return va_arg(*ap, long long);
  800f01:	8b 45 14             	mov    0x14(%ebp),%eax
  800f04:	8b 50 04             	mov    0x4(%eax),%edx
  800f07:	8b 00                	mov    (%eax),%eax
  800f09:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800f0c:	89 55 dc             	mov    %edx,-0x24(%ebp)
  800f0f:	8b 45 14             	mov    0x14(%ebp),%eax
  800f12:	8d 40 08             	lea    0x8(%eax),%eax
  800f15:	89 45 14             	mov    %eax,0x14(%ebp)
			if ((long long) num < 0) {
  800f18:	8b 55 d8             	mov    -0x28(%ebp),%edx
  800f1b:	8b 4d dc             	mov    -0x24(%ebp),%ecx
			base = 10;
  800f1e:	b8 0a 00 00 00       	mov    $0xa,%eax
			if ((long long) num < 0) {
  800f23:	85 c9                	test   %ecx,%ecx
  800f25:	0f 89 ca 00 00 00    	jns    800ff5 <vprintfmt+0x35b>
				putch('-', putdat);
  800f2b:	83 ec 08             	sub    $0x8,%esp
  800f2e:	53                   	push   %ebx
  800f2f:	6a 2d                	push   $0x2d
  800f31:	ff d6                	call   *%esi
				num = -(long long) num;
  800f33:	8b 55 d8             	mov    -0x28(%ebp),%edx
  800f36:	8b 4d dc             	mov    -0x24(%ebp),%ecx
  800f39:	f7 da                	neg    %edx
  800f3b:	83 d1 00             	adc    $0x0,%ecx
  800f3e:	f7 d9                	neg    %ecx
  800f40:	83 c4 10             	add    $0x10,%esp
			base = 10;
  800f43:	b8 0a 00 00 00       	mov    $0xa,%eax
  800f48:	e9 a8 00 00 00       	jmp    800ff5 <vprintfmt+0x35b>
		return va_arg(*ap, int);
  800f4d:	8b 45 14             	mov    0x14(%ebp),%eax
  800f50:	8b 00                	mov    (%eax),%eax
  800f52:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800f55:	99                   	cltd   
  800f56:	89 55 dc             	mov    %edx,-0x24(%ebp)
  800f59:	8b 45 14             	mov    0x14(%ebp),%eax
  800f5c:	8d 40 04             	lea    0x4(%eax),%eax
  800f5f:	89 45 14             	mov    %eax,0x14(%ebp)
  800f62:	eb b4                	jmp    800f18 <vprintfmt+0x27e>
	if (lflag >= 2)
  800f64:	83 f9 01             	cmp    $0x1,%ecx
  800f67:	7f 1b                	jg     800f84 <vprintfmt+0x2ea>
	else if (lflag)
  800f69:	85 c9                	test   %ecx,%ecx
  800f6b:	74 2c                	je     800f99 <vprintfmt+0x2ff>
		return va_arg(*ap, unsigned long);
  800f6d:	8b 45 14             	mov    0x14(%ebp),%eax
  800f70:	8b 10                	mov    (%eax),%edx
  800f72:	b9 00 00 00 00       	mov    $0x0,%ecx
  800f77:	8d 40 04             	lea    0x4(%eax),%eax
  800f7a:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 10;
  800f7d:	b8 0a 00 00 00       	mov    $0xa,%eax
		return va_arg(*ap, unsigned long);
  800f82:	eb 71                	jmp    800ff5 <vprintfmt+0x35b>
		return va_arg(*ap, unsigned long long);
  800f84:	8b 45 14             	mov    0x14(%ebp),%eax
  800f87:	8b 10                	mov    (%eax),%edx
  800f89:	8b 48 04             	mov    0x4(%eax),%ecx
  800f8c:	8d 40 08             	lea    0x8(%eax),%eax
  800f8f:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 10;
  800f92:	b8 0a 00 00 00       	mov    $0xa,%eax
		return va_arg(*ap, unsigned long long);
  800f97:	eb 5c                	jmp    800ff5 <vprintfmt+0x35b>
		return va_arg(*ap, unsigned int);
  800f99:	8b 45 14             	mov    0x14(%ebp),%eax
  800f9c:	8b 10                	mov    (%eax),%edx
  800f9e:	b9 00 00 00 00       	mov    $0x0,%ecx
  800fa3:	8d 40 04             	lea    0x4(%eax),%eax
  800fa6:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 10;
  800fa9:	b8 0a 00 00 00       	mov    $0xa,%eax
		return va_arg(*ap, unsigned int);
  800fae:	eb 45                	jmp    800ff5 <vprintfmt+0x35b>
			putch('X', putdat);
  800fb0:	83 ec 08             	sub    $0x8,%esp
  800fb3:	53                   	push   %ebx
  800fb4:	6a 58                	push   $0x58
  800fb6:	ff d6                	call   *%esi
			putch('X', putdat);
  800fb8:	83 c4 08             	add    $0x8,%esp
  800fbb:	53                   	push   %ebx
  800fbc:	6a 58                	push   $0x58
  800fbe:	ff d6                	call   *%esi
			putch('X', putdat);
  800fc0:	83 c4 08             	add    $0x8,%esp
  800fc3:	53                   	push   %ebx
  800fc4:	6a 58                	push   $0x58
  800fc6:	ff d6                	call   *%esi
			break;
  800fc8:	83 c4 10             	add    $0x10,%esp
  800fcb:	eb 42                	jmp    80100f <vprintfmt+0x375>
			putch('0', putdat);
  800fcd:	83 ec 08             	sub    $0x8,%esp
  800fd0:	53                   	push   %ebx
  800fd1:	6a 30                	push   $0x30
  800fd3:	ff d6                	call   *%esi
			putch('x', putdat);
  800fd5:	83 c4 08             	add    $0x8,%esp
  800fd8:	53                   	push   %ebx
  800fd9:	6a 78                	push   $0x78
  800fdb:	ff d6                	call   *%esi
			num = (unsigned long long)
  800fdd:	8b 45 14             	mov    0x14(%ebp),%eax
  800fe0:	8b 10                	mov    (%eax),%edx
  800fe2:	b9 00 00 00 00       	mov    $0x0,%ecx
			goto number;
  800fe7:	83 c4 10             	add    $0x10,%esp
				(uintptr_t) va_arg(ap, void *);
  800fea:	8d 40 04             	lea    0x4(%eax),%eax
  800fed:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 16;
  800ff0:	b8 10 00 00 00       	mov    $0x10,%eax
			printnum(putch, putdat, num, base, width, padc);
  800ff5:	83 ec 0c             	sub    $0xc,%esp
  800ff8:	0f be 7d d3          	movsbl -0x2d(%ebp),%edi
  800ffc:	57                   	push   %edi
  800ffd:	ff 75 d4             	pushl  -0x2c(%ebp)
  801000:	50                   	push   %eax
  801001:	51                   	push   %ecx
  801002:	52                   	push   %edx
  801003:	89 da                	mov    %ebx,%edx
  801005:	89 f0                	mov    %esi,%eax
  801007:	e8 a3 fb ff ff       	call   800baf <printnum>
			break;
  80100c:	83 c4 20             	add    $0x20,%esp
			if ((p = va_arg(ap, char *)) == NULL)
  80100f:	8b 7d e4             	mov    -0x1c(%ebp),%edi
		while ((ch = *(unsigned char *) fmt++) != '%') {
  801012:	83 c7 01             	add    $0x1,%edi
  801015:	0f b6 47 ff          	movzbl -0x1(%edi),%eax
  801019:	83 f8 25             	cmp    $0x25,%eax
  80101c:	0f 84 93 fc ff ff    	je     800cb5 <vprintfmt+0x1b>
			if (ch == '\0')
  801022:	85 c0                	test   %eax,%eax
  801024:	0f 84 8b 00 00 00    	je     8010b5 <vprintfmt+0x41b>
			putch(ch, putdat);
  80102a:	83 ec 08             	sub    $0x8,%esp
  80102d:	53                   	push   %ebx
  80102e:	50                   	push   %eax
  80102f:	ff d6                	call   *%esi
  801031:	83 c4 10             	add    $0x10,%esp
  801034:	eb dc                	jmp    801012 <vprintfmt+0x378>
	if (lflag >= 2)
  801036:	83 f9 01             	cmp    $0x1,%ecx
  801039:	7f 1b                	jg     801056 <vprintfmt+0x3bc>
	else if (lflag)
  80103b:	85 c9                	test   %ecx,%ecx
  80103d:	74 2c                	je     80106b <vprintfmt+0x3d1>
		return va_arg(*ap, unsigned long);
  80103f:	8b 45 14             	mov    0x14(%ebp),%eax
  801042:	8b 10                	mov    (%eax),%edx
  801044:	b9 00 00 00 00       	mov    $0x0,%ecx
  801049:	8d 40 04             	lea    0x4(%eax),%eax
  80104c:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 16;
  80104f:	b8 10 00 00 00       	mov    $0x10,%eax
		return va_arg(*ap, unsigned long);
  801054:	eb 9f                	jmp    800ff5 <vprintfmt+0x35b>
		return va_arg(*ap, unsigned long long);
  801056:	8b 45 14             	mov    0x14(%ebp),%eax
  801059:	8b 10                	mov    (%eax),%edx
  80105b:	8b 48 04             	mov    0x4(%eax),%ecx
  80105e:	8d 40 08             	lea    0x8(%eax),%eax
  801061:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 16;
  801064:	b8 10 00 00 00       	mov    $0x10,%eax
		return va_arg(*ap, unsigned long long);
  801069:	eb 8a                	jmp    800ff5 <vprintfmt+0x35b>
		return va_arg(*ap, unsigned int);
  80106b:	8b 45 14             	mov    0x14(%ebp),%eax
  80106e:	8b 10                	mov    (%eax),%edx
  801070:	b9 00 00 00 00       	mov    $0x0,%ecx
  801075:	8d 40 04             	lea    0x4(%eax),%eax
  801078:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 16;
  80107b:	b8 10 00 00 00       	mov    $0x10,%eax
		return va_arg(*ap, unsigned int);
  801080:	e9 70 ff ff ff       	jmp    800ff5 <vprintfmt+0x35b>
			putch(ch, putdat);
  801085:	83 ec 08             	sub    $0x8,%esp
  801088:	53                   	push   %ebx
  801089:	6a 25                	push   $0x25
  80108b:	ff d6                	call   *%esi
			break;
  80108d:	83 c4 10             	add    $0x10,%esp
  801090:	e9 7a ff ff ff       	jmp    80100f <vprintfmt+0x375>
			putch('%', putdat);
  801095:	83 ec 08             	sub    $0x8,%esp
  801098:	53                   	push   %ebx
  801099:	6a 25                	push   $0x25
  80109b:	ff d6                	call   *%esi
			for (fmt--; fmt[-1] != '%'; fmt--)
  80109d:	83 c4 10             	add    $0x10,%esp
  8010a0:	89 f8                	mov    %edi,%eax
  8010a2:	80 78 ff 25          	cmpb   $0x25,-0x1(%eax)
  8010a6:	74 05                	je     8010ad <vprintfmt+0x413>
  8010a8:	83 e8 01             	sub    $0x1,%eax
  8010ab:	eb f5                	jmp    8010a2 <vprintfmt+0x408>
  8010ad:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  8010b0:	e9 5a ff ff ff       	jmp    80100f <vprintfmt+0x375>
}
  8010b5:	8d 65 f4             	lea    -0xc(%ebp),%esp
  8010b8:	5b                   	pop    %ebx
  8010b9:	5e                   	pop    %esi
  8010ba:	5f                   	pop    %edi
  8010bb:	5d                   	pop    %ebp
  8010bc:	c3                   	ret    

008010bd <vsnprintf>:

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
  8010bd:	f3 0f 1e fb          	endbr32 
  8010c1:	55                   	push   %ebp
  8010c2:	89 e5                	mov    %esp,%ebp
  8010c4:	83 ec 18             	sub    $0x18,%esp
  8010c7:	8b 45 08             	mov    0x8(%ebp),%eax
  8010ca:	8b 55 0c             	mov    0xc(%ebp),%edx
	struct sprintbuf b = {buf, buf+n-1, 0};
  8010cd:	89 45 ec             	mov    %eax,-0x14(%ebp)
  8010d0:	8d 4c 10 ff          	lea    -0x1(%eax,%edx,1),%ecx
  8010d4:	89 4d f0             	mov    %ecx,-0x10(%ebp)
  8010d7:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)

	if (buf == NULL || n < 1)
  8010de:	85 c0                	test   %eax,%eax
  8010e0:	74 26                	je     801108 <vsnprintf+0x4b>
  8010e2:	85 d2                	test   %edx,%edx
  8010e4:	7e 22                	jle    801108 <vsnprintf+0x4b>
		return -E_INVAL;

	// print the string to the buffer
	vprintfmt((void*)sprintputch, &b, fmt, ap);
  8010e6:	ff 75 14             	pushl  0x14(%ebp)
  8010e9:	ff 75 10             	pushl  0x10(%ebp)
  8010ec:	8d 45 ec             	lea    -0x14(%ebp),%eax
  8010ef:	50                   	push   %eax
  8010f0:	68 58 0c 80 00       	push   $0x800c58
  8010f5:	e8 a0 fb ff ff       	call   800c9a <vprintfmt>

	// null terminate the buffer
	*b.buf = '\0';
  8010fa:	8b 45 ec             	mov    -0x14(%ebp),%eax
  8010fd:	c6 00 00             	movb   $0x0,(%eax)

	return b.cnt;
  801100:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801103:	83 c4 10             	add    $0x10,%esp
}
  801106:	c9                   	leave  
  801107:	c3                   	ret    
		return -E_INVAL;
  801108:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  80110d:	eb f7                	jmp    801106 <vsnprintf+0x49>

0080110f <snprintf>:

int
snprintf(char *buf, int n, const char *fmt, ...)
{
  80110f:	f3 0f 1e fb          	endbr32 
  801113:	55                   	push   %ebp
  801114:	89 e5                	mov    %esp,%ebp
  801116:	83 ec 08             	sub    $0x8,%esp
	va_list ap;
	int rc;

	va_start(ap, fmt);
  801119:	8d 45 14             	lea    0x14(%ebp),%eax
	rc = vsnprintf(buf, n, fmt, ap);
  80111c:	50                   	push   %eax
  80111d:	ff 75 10             	pushl  0x10(%ebp)
  801120:	ff 75 0c             	pushl  0xc(%ebp)
  801123:	ff 75 08             	pushl  0x8(%ebp)
  801126:	e8 92 ff ff ff       	call   8010bd <vsnprintf>
	va_end(ap);

	return rc;
}
  80112b:	c9                   	leave  
  80112c:	c3                   	ret    

0080112d <readline>:
#define BUFLEN 1024
static char buf[BUFLEN];

char *
readline(const char *prompt)
{
  80112d:	f3 0f 1e fb          	endbr32 
  801131:	55                   	push   %ebp
  801132:	89 e5                	mov    %esp,%ebp
  801134:	57                   	push   %edi
  801135:	56                   	push   %esi
  801136:	53                   	push   %ebx
  801137:	83 ec 0c             	sub    $0xc,%esp
  80113a:	8b 45 08             	mov    0x8(%ebp),%eax

#if JOS_KERNEL
	if (prompt != NULL)
		cprintf("%s", prompt);
#else
	if (prompt != NULL)
  80113d:	85 c0                	test   %eax,%eax
  80113f:	74 13                	je     801154 <readline+0x27>
		fprintf(1, "%s", prompt);
  801141:	83 ec 04             	sub    $0x4,%esp
  801144:	50                   	push   %eax
  801145:	68 61 36 80 00       	push   $0x803661
  80114a:	6a 01                	push   $0x1
  80114c:	e8 3f 15 00 00       	call   802690 <fprintf>
  801151:	83 c4 10             	add    $0x10,%esp
#endif

	i = 0;
	echoing = iscons(0);
  801154:	83 ec 0c             	sub    $0xc,%esp
  801157:	6a 00                	push   $0x0
  801159:	e8 5a f8 ff ff       	call   8009b8 <iscons>
  80115e:	89 c7                	mov    %eax,%edi
  801160:	83 c4 10             	add    $0x10,%esp
	i = 0;
  801163:	be 00 00 00 00       	mov    $0x0,%esi
  801168:	eb 57                	jmp    8011c1 <readline+0x94>
	while (1) {
		c = getchar();
		if (c < 0) {
			if (c != -E_EOF)
				cprintf("read error: %e\n", c);
			return NULL;
  80116a:	b8 00 00 00 00       	mov    $0x0,%eax
			if (c != -E_EOF)
  80116f:	83 fb f8             	cmp    $0xfffffff8,%ebx
  801172:	75 08                	jne    80117c <readline+0x4f>
				cputchar('\n');
			buf[i] = 0;
			return buf;
		}
	}
}
  801174:	8d 65 f4             	lea    -0xc(%ebp),%esp
  801177:	5b                   	pop    %ebx
  801178:	5e                   	pop    %esi
  801179:	5f                   	pop    %edi
  80117a:	5d                   	pop    %ebp
  80117b:	c3                   	ret    
				cprintf("read error: %e\n", c);
  80117c:	83 ec 08             	sub    $0x8,%esp
  80117f:	53                   	push   %ebx
  801180:	68 3f 3a 80 00       	push   $0x803a3f
  801185:	e8 0d fa ff ff       	call   800b97 <cprintf>
  80118a:	83 c4 10             	add    $0x10,%esp
			return NULL;
  80118d:	b8 00 00 00 00       	mov    $0x0,%eax
  801192:	eb e0                	jmp    801174 <readline+0x47>
			if (echoing)
  801194:	85 ff                	test   %edi,%edi
  801196:	75 05                	jne    80119d <readline+0x70>
			i--;
  801198:	83 ee 01             	sub    $0x1,%esi
  80119b:	eb 24                	jmp    8011c1 <readline+0x94>
				cputchar('\b');
  80119d:	83 ec 0c             	sub    $0xc,%esp
  8011a0:	6a 08                	push   $0x8
  8011a2:	e8 c4 f7 ff ff       	call   80096b <cputchar>
  8011a7:	83 c4 10             	add    $0x10,%esp
  8011aa:	eb ec                	jmp    801198 <readline+0x6b>
				cputchar(c);
  8011ac:	83 ec 0c             	sub    $0xc,%esp
  8011af:	53                   	push   %ebx
  8011b0:	e8 b6 f7 ff ff       	call   80096b <cputchar>
  8011b5:	83 c4 10             	add    $0x10,%esp
			buf[i++] = c;
  8011b8:	88 9e 20 50 80 00    	mov    %bl,0x805020(%esi)
  8011be:	8d 76 01             	lea    0x1(%esi),%esi
		c = getchar();
  8011c1:	e8 c5 f7 ff ff       	call   80098b <getchar>
  8011c6:	89 c3                	mov    %eax,%ebx
		if (c < 0) {
  8011c8:	85 c0                	test   %eax,%eax
  8011ca:	78 9e                	js     80116a <readline+0x3d>
		} else if ((c == '\b' || c == '\x7f') && i > 0) {
  8011cc:	83 f8 08             	cmp    $0x8,%eax
  8011cf:	0f 94 c2             	sete   %dl
  8011d2:	83 f8 7f             	cmp    $0x7f,%eax
  8011d5:	0f 94 c0             	sete   %al
  8011d8:	08 c2                	or     %al,%dl
  8011da:	74 04                	je     8011e0 <readline+0xb3>
  8011dc:	85 f6                	test   %esi,%esi
  8011de:	7f b4                	jg     801194 <readline+0x67>
		} else if (c >= ' ' && i < BUFLEN-1) {
  8011e0:	83 fb 1f             	cmp    $0x1f,%ebx
  8011e3:	7e 0e                	jle    8011f3 <readline+0xc6>
  8011e5:	81 fe fe 03 00 00    	cmp    $0x3fe,%esi
  8011eb:	7f 06                	jg     8011f3 <readline+0xc6>
			if (echoing)
  8011ed:	85 ff                	test   %edi,%edi
  8011ef:	74 c7                	je     8011b8 <readline+0x8b>
  8011f1:	eb b9                	jmp    8011ac <readline+0x7f>
		} else if (c == '\n' || c == '\r') {
  8011f3:	83 fb 0a             	cmp    $0xa,%ebx
  8011f6:	74 05                	je     8011fd <readline+0xd0>
  8011f8:	83 fb 0d             	cmp    $0xd,%ebx
  8011fb:	75 c4                	jne    8011c1 <readline+0x94>
			if (echoing)
  8011fd:	85 ff                	test   %edi,%edi
  8011ff:	75 11                	jne    801212 <readline+0xe5>
			buf[i] = 0;
  801201:	c6 86 20 50 80 00 00 	movb   $0x0,0x805020(%esi)
			return buf;
  801208:	b8 20 50 80 00       	mov    $0x805020,%eax
  80120d:	e9 62 ff ff ff       	jmp    801174 <readline+0x47>
				cputchar('\n');
  801212:	83 ec 0c             	sub    $0xc,%esp
  801215:	6a 0a                	push   $0xa
  801217:	e8 4f f7 ff ff       	call   80096b <cputchar>
  80121c:	83 c4 10             	add    $0x10,%esp
  80121f:	eb e0                	jmp    801201 <readline+0xd4>

00801221 <strlen>:
// Primespipe runs 3x faster this way.
#define ASM 1

int
strlen(const char *s)
{
  801221:	f3 0f 1e fb          	endbr32 
  801225:	55                   	push   %ebp
  801226:	89 e5                	mov    %esp,%ebp
  801228:	8b 55 08             	mov    0x8(%ebp),%edx
	int n;

	for (n = 0; *s != '\0'; s++)
  80122b:	b8 00 00 00 00       	mov    $0x0,%eax
  801230:	80 3c 02 00          	cmpb   $0x0,(%edx,%eax,1)
  801234:	74 05                	je     80123b <strlen+0x1a>
		n++;
  801236:	83 c0 01             	add    $0x1,%eax
  801239:	eb f5                	jmp    801230 <strlen+0xf>
	return n;
}
  80123b:	5d                   	pop    %ebp
  80123c:	c3                   	ret    

0080123d <strnlen>:

int
strnlen(const char *s, size_t size)
{
  80123d:	f3 0f 1e fb          	endbr32 
  801241:	55                   	push   %ebp
  801242:	89 e5                	mov    %esp,%ebp
  801244:	8b 4d 08             	mov    0x8(%ebp),%ecx
  801247:	8b 55 0c             	mov    0xc(%ebp),%edx
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  80124a:	b8 00 00 00 00       	mov    $0x0,%eax
  80124f:	39 d0                	cmp    %edx,%eax
  801251:	74 0d                	je     801260 <strnlen+0x23>
  801253:	80 3c 01 00          	cmpb   $0x0,(%ecx,%eax,1)
  801257:	74 05                	je     80125e <strnlen+0x21>
		n++;
  801259:	83 c0 01             	add    $0x1,%eax
  80125c:	eb f1                	jmp    80124f <strnlen+0x12>
  80125e:	89 c2                	mov    %eax,%edx
	return n;
}
  801260:	89 d0                	mov    %edx,%eax
  801262:	5d                   	pop    %ebp
  801263:	c3                   	ret    

00801264 <strcpy>:

char *
strcpy(char *dst, const char *src)
{
  801264:	f3 0f 1e fb          	endbr32 
  801268:	55                   	push   %ebp
  801269:	89 e5                	mov    %esp,%ebp
  80126b:	53                   	push   %ebx
  80126c:	8b 4d 08             	mov    0x8(%ebp),%ecx
  80126f:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	char *ret;

	ret = dst;
	while ((*dst++ = *src++) != '\0')
  801272:	b8 00 00 00 00       	mov    $0x0,%eax
  801277:	0f b6 14 03          	movzbl (%ebx,%eax,1),%edx
  80127b:	88 14 01             	mov    %dl,(%ecx,%eax,1)
  80127e:	83 c0 01             	add    $0x1,%eax
  801281:	84 d2                	test   %dl,%dl
  801283:	75 f2                	jne    801277 <strcpy+0x13>
		/* do nothing */;
	return ret;
}
  801285:	89 c8                	mov    %ecx,%eax
  801287:	5b                   	pop    %ebx
  801288:	5d                   	pop    %ebp
  801289:	c3                   	ret    

0080128a <strcat>:

char *
strcat(char *dst, const char *src)
{
  80128a:	f3 0f 1e fb          	endbr32 
  80128e:	55                   	push   %ebp
  80128f:	89 e5                	mov    %esp,%ebp
  801291:	53                   	push   %ebx
  801292:	83 ec 10             	sub    $0x10,%esp
  801295:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int len = strlen(dst);
  801298:	53                   	push   %ebx
  801299:	e8 83 ff ff ff       	call   801221 <strlen>
  80129e:	83 c4 08             	add    $0x8,%esp
	strcpy(dst + len, src);
  8012a1:	ff 75 0c             	pushl  0xc(%ebp)
  8012a4:	01 d8                	add    %ebx,%eax
  8012a6:	50                   	push   %eax
  8012a7:	e8 b8 ff ff ff       	call   801264 <strcpy>
	return dst;
}
  8012ac:	89 d8                	mov    %ebx,%eax
  8012ae:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  8012b1:	c9                   	leave  
  8012b2:	c3                   	ret    

008012b3 <strncpy>:

char *
strncpy(char *dst, const char *src, size_t size) {
  8012b3:	f3 0f 1e fb          	endbr32 
  8012b7:	55                   	push   %ebp
  8012b8:	89 e5                	mov    %esp,%ebp
  8012ba:	56                   	push   %esi
  8012bb:	53                   	push   %ebx
  8012bc:	8b 75 08             	mov    0x8(%ebp),%esi
  8012bf:	8b 55 0c             	mov    0xc(%ebp),%edx
  8012c2:	89 f3                	mov    %esi,%ebx
  8012c4:	03 5d 10             	add    0x10(%ebp),%ebx
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  8012c7:	89 f0                	mov    %esi,%eax
  8012c9:	39 d8                	cmp    %ebx,%eax
  8012cb:	74 11                	je     8012de <strncpy+0x2b>
		*dst++ = *src;
  8012cd:	83 c0 01             	add    $0x1,%eax
  8012d0:	0f b6 0a             	movzbl (%edx),%ecx
  8012d3:	88 48 ff             	mov    %cl,-0x1(%eax)
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
  8012d6:	80 f9 01             	cmp    $0x1,%cl
  8012d9:	83 da ff             	sbb    $0xffffffff,%edx
  8012dc:	eb eb                	jmp    8012c9 <strncpy+0x16>
	}
	return ret;
}
  8012de:	89 f0                	mov    %esi,%eax
  8012e0:	5b                   	pop    %ebx
  8012e1:	5e                   	pop    %esi
  8012e2:	5d                   	pop    %ebp
  8012e3:	c3                   	ret    

008012e4 <strlcpy>:

size_t
strlcpy(char *dst, const char *src, size_t size)
{
  8012e4:	f3 0f 1e fb          	endbr32 
  8012e8:	55                   	push   %ebp
  8012e9:	89 e5                	mov    %esp,%ebp
  8012eb:	56                   	push   %esi
  8012ec:	53                   	push   %ebx
  8012ed:	8b 75 08             	mov    0x8(%ebp),%esi
  8012f0:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8012f3:	8b 55 10             	mov    0x10(%ebp),%edx
  8012f6:	89 f0                	mov    %esi,%eax
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
  8012f8:	85 d2                	test   %edx,%edx
  8012fa:	74 21                	je     80131d <strlcpy+0x39>
  8012fc:	8d 44 16 ff          	lea    -0x1(%esi,%edx,1),%eax
  801300:	89 f2                	mov    %esi,%edx
		while (--size > 0 && *src != '\0')
  801302:	39 c2                	cmp    %eax,%edx
  801304:	74 14                	je     80131a <strlcpy+0x36>
  801306:	0f b6 19             	movzbl (%ecx),%ebx
  801309:	84 db                	test   %bl,%bl
  80130b:	74 0b                	je     801318 <strlcpy+0x34>
			*dst++ = *src++;
  80130d:	83 c1 01             	add    $0x1,%ecx
  801310:	83 c2 01             	add    $0x1,%edx
  801313:	88 5a ff             	mov    %bl,-0x1(%edx)
  801316:	eb ea                	jmp    801302 <strlcpy+0x1e>
  801318:	89 d0                	mov    %edx,%eax
		*dst = '\0';
  80131a:	c6 00 00             	movb   $0x0,(%eax)
	}
	return dst - dst_in;
  80131d:	29 f0                	sub    %esi,%eax
}
  80131f:	5b                   	pop    %ebx
  801320:	5e                   	pop    %esi
  801321:	5d                   	pop    %ebp
  801322:	c3                   	ret    

00801323 <strcmp>:

int
strcmp(const char *p, const char *q)
{
  801323:	f3 0f 1e fb          	endbr32 
  801327:	55                   	push   %ebp
  801328:	89 e5                	mov    %esp,%ebp
  80132a:	8b 4d 08             	mov    0x8(%ebp),%ecx
  80132d:	8b 55 0c             	mov    0xc(%ebp),%edx
	while (*p && *p == *q)
  801330:	0f b6 01             	movzbl (%ecx),%eax
  801333:	84 c0                	test   %al,%al
  801335:	74 0c                	je     801343 <strcmp+0x20>
  801337:	3a 02                	cmp    (%edx),%al
  801339:	75 08                	jne    801343 <strcmp+0x20>
		p++, q++;
  80133b:	83 c1 01             	add    $0x1,%ecx
  80133e:	83 c2 01             	add    $0x1,%edx
  801341:	eb ed                	jmp    801330 <strcmp+0xd>
	return (int) ((unsigned char) *p - (unsigned char) *q);
  801343:	0f b6 c0             	movzbl %al,%eax
  801346:	0f b6 12             	movzbl (%edx),%edx
  801349:	29 d0                	sub    %edx,%eax
}
  80134b:	5d                   	pop    %ebp
  80134c:	c3                   	ret    

0080134d <strncmp>:

int
strncmp(const char *p, const char *q, size_t n)
{
  80134d:	f3 0f 1e fb          	endbr32 
  801351:	55                   	push   %ebp
  801352:	89 e5                	mov    %esp,%ebp
  801354:	53                   	push   %ebx
  801355:	8b 45 08             	mov    0x8(%ebp),%eax
  801358:	8b 55 0c             	mov    0xc(%ebp),%edx
  80135b:	89 c3                	mov    %eax,%ebx
  80135d:	03 5d 10             	add    0x10(%ebp),%ebx
	while (n > 0 && *p && *p == *q)
  801360:	eb 06                	jmp    801368 <strncmp+0x1b>
		n--, p++, q++;
  801362:	83 c0 01             	add    $0x1,%eax
  801365:	83 c2 01             	add    $0x1,%edx
	while (n > 0 && *p && *p == *q)
  801368:	39 d8                	cmp    %ebx,%eax
  80136a:	74 16                	je     801382 <strncmp+0x35>
  80136c:	0f b6 08             	movzbl (%eax),%ecx
  80136f:	84 c9                	test   %cl,%cl
  801371:	74 04                	je     801377 <strncmp+0x2a>
  801373:	3a 0a                	cmp    (%edx),%cl
  801375:	74 eb                	je     801362 <strncmp+0x15>
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
  801377:	0f b6 00             	movzbl (%eax),%eax
  80137a:	0f b6 12             	movzbl (%edx),%edx
  80137d:	29 d0                	sub    %edx,%eax
}
  80137f:	5b                   	pop    %ebx
  801380:	5d                   	pop    %ebp
  801381:	c3                   	ret    
		return 0;
  801382:	b8 00 00 00 00       	mov    $0x0,%eax
  801387:	eb f6                	jmp    80137f <strncmp+0x32>

00801389 <strchr>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
  801389:	f3 0f 1e fb          	endbr32 
  80138d:	55                   	push   %ebp
  80138e:	89 e5                	mov    %esp,%ebp
  801390:	8b 45 08             	mov    0x8(%ebp),%eax
  801393:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  801397:	0f b6 10             	movzbl (%eax),%edx
  80139a:	84 d2                	test   %dl,%dl
  80139c:	74 09                	je     8013a7 <strchr+0x1e>
		if (*s == c)
  80139e:	38 ca                	cmp    %cl,%dl
  8013a0:	74 0a                	je     8013ac <strchr+0x23>
	for (; *s; s++)
  8013a2:	83 c0 01             	add    $0x1,%eax
  8013a5:	eb f0                	jmp    801397 <strchr+0xe>
			return (char *) s;
	return 0;
  8013a7:	b8 00 00 00 00       	mov    $0x0,%eax
}
  8013ac:	5d                   	pop    %ebp
  8013ad:	c3                   	ret    

008013ae <strfind>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
  8013ae:	f3 0f 1e fb          	endbr32 
  8013b2:	55                   	push   %ebp
  8013b3:	89 e5                	mov    %esp,%ebp
  8013b5:	8b 45 08             	mov    0x8(%ebp),%eax
  8013b8:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  8013bc:	0f b6 10             	movzbl (%eax),%edx
		if (*s == c)
  8013bf:	38 ca                	cmp    %cl,%dl
  8013c1:	74 09                	je     8013cc <strfind+0x1e>
  8013c3:	84 d2                	test   %dl,%dl
  8013c5:	74 05                	je     8013cc <strfind+0x1e>
	for (; *s; s++)
  8013c7:	83 c0 01             	add    $0x1,%eax
  8013ca:	eb f0                	jmp    8013bc <strfind+0xe>
			break;
	return (char *) s;
}
  8013cc:	5d                   	pop    %ebp
  8013cd:	c3                   	ret    

008013ce <memset>:

#if ASM
void *
memset(void *v, int c, size_t n)
{
  8013ce:	f3 0f 1e fb          	endbr32 
  8013d2:	55                   	push   %ebp
  8013d3:	89 e5                	mov    %esp,%ebp
  8013d5:	57                   	push   %edi
  8013d6:	56                   	push   %esi
  8013d7:	53                   	push   %ebx
  8013d8:	8b 7d 08             	mov    0x8(%ebp),%edi
  8013db:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *p;

	if (n == 0)
  8013de:	85 c9                	test   %ecx,%ecx
  8013e0:	74 31                	je     801413 <memset+0x45>
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  8013e2:	89 f8                	mov    %edi,%eax
  8013e4:	09 c8                	or     %ecx,%eax
  8013e6:	a8 03                	test   $0x3,%al
  8013e8:	75 23                	jne    80140d <memset+0x3f>
		c &= 0xFF;
  8013ea:	0f b6 55 0c          	movzbl 0xc(%ebp),%edx
		c = (c<<24)|(c<<16)|(c<<8)|c;
  8013ee:	89 d3                	mov    %edx,%ebx
  8013f0:	c1 e3 08             	shl    $0x8,%ebx
  8013f3:	89 d0                	mov    %edx,%eax
  8013f5:	c1 e0 18             	shl    $0x18,%eax
  8013f8:	89 d6                	mov    %edx,%esi
  8013fa:	c1 e6 10             	shl    $0x10,%esi
  8013fd:	09 f0                	or     %esi,%eax
  8013ff:	09 c2                	or     %eax,%edx
  801401:	09 da                	or     %ebx,%edx
		asm volatile("cld; rep stosl\n"
			:: "D" (v), "a" (c), "c" (n/4)
  801403:	c1 e9 02             	shr    $0x2,%ecx
		asm volatile("cld; rep stosl\n"
  801406:	89 d0                	mov    %edx,%eax
  801408:	fc                   	cld    
  801409:	f3 ab                	rep stos %eax,%es:(%edi)
  80140b:	eb 06                	jmp    801413 <memset+0x45>
			: "cc", "memory");
	} else
		asm volatile("cld; rep stosb\n"
  80140d:	8b 45 0c             	mov    0xc(%ebp),%eax
  801410:	fc                   	cld    
  801411:	f3 aa                	rep stos %al,%es:(%edi)
			:: "D" (v), "a" (c), "c" (n)
			: "cc", "memory");
	return v;
}
  801413:	89 f8                	mov    %edi,%eax
  801415:	5b                   	pop    %ebx
  801416:	5e                   	pop    %esi
  801417:	5f                   	pop    %edi
  801418:	5d                   	pop    %ebp
  801419:	c3                   	ret    

0080141a <memmove>:

void *
memmove(void *dst, const void *src, size_t n)
{
  80141a:	f3 0f 1e fb          	endbr32 
  80141e:	55                   	push   %ebp
  80141f:	89 e5                	mov    %esp,%ebp
  801421:	57                   	push   %edi
  801422:	56                   	push   %esi
  801423:	8b 45 08             	mov    0x8(%ebp),%eax
  801426:	8b 75 0c             	mov    0xc(%ebp),%esi
  801429:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const char *s;
	char *d;

	s = src;
	d = dst;
	if (s < d && s + n > d) {
  80142c:	39 c6                	cmp    %eax,%esi
  80142e:	73 32                	jae    801462 <memmove+0x48>
  801430:	8d 14 0e             	lea    (%esi,%ecx,1),%edx
  801433:	39 c2                	cmp    %eax,%edx
  801435:	76 2b                	jbe    801462 <memmove+0x48>
		s += n;
		d += n;
  801437:	8d 3c 08             	lea    (%eax,%ecx,1),%edi
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  80143a:	89 fe                	mov    %edi,%esi
  80143c:	09 ce                	or     %ecx,%esi
  80143e:	09 d6                	or     %edx,%esi
  801440:	f7 c6 03 00 00 00    	test   $0x3,%esi
  801446:	75 0e                	jne    801456 <memmove+0x3c>
			asm volatile("std; rep movsl\n"
				:: "D" (d-4), "S" (s-4), "c" (n/4) : "cc", "memory");
  801448:	83 ef 04             	sub    $0x4,%edi
  80144b:	8d 72 fc             	lea    -0x4(%edx),%esi
  80144e:	c1 e9 02             	shr    $0x2,%ecx
			asm volatile("std; rep movsl\n"
  801451:	fd                   	std    
  801452:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
  801454:	eb 09                	jmp    80145f <memmove+0x45>
		else
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
  801456:	83 ef 01             	sub    $0x1,%edi
  801459:	8d 72 ff             	lea    -0x1(%edx),%esi
			asm volatile("std; rep movsb\n"
  80145c:	fd                   	std    
  80145d:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
  80145f:	fc                   	cld    
  801460:	eb 1a                	jmp    80147c <memmove+0x62>
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  801462:	89 c2                	mov    %eax,%edx
  801464:	09 ca                	or     %ecx,%edx
  801466:	09 f2                	or     %esi,%edx
  801468:	f6 c2 03             	test   $0x3,%dl
  80146b:	75 0a                	jne    801477 <memmove+0x5d>
			asm volatile("cld; rep movsl\n"
				:: "D" (d), "S" (s), "c" (n/4) : "cc", "memory");
  80146d:	c1 e9 02             	shr    $0x2,%ecx
			asm volatile("cld; rep movsl\n"
  801470:	89 c7                	mov    %eax,%edi
  801472:	fc                   	cld    
  801473:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
  801475:	eb 05                	jmp    80147c <memmove+0x62>
		else
			asm volatile("cld; rep movsb\n"
  801477:	89 c7                	mov    %eax,%edi
  801479:	fc                   	cld    
  80147a:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d), "S" (s), "c" (n) : "cc", "memory");
	}
	return dst;
}
  80147c:	5e                   	pop    %esi
  80147d:	5f                   	pop    %edi
  80147e:	5d                   	pop    %ebp
  80147f:	c3                   	ret    

00801480 <memcpy>:
}
#endif

void *
memcpy(void *dst, const void *src, size_t n)
{
  801480:	f3 0f 1e fb          	endbr32 
  801484:	55                   	push   %ebp
  801485:	89 e5                	mov    %esp,%ebp
  801487:	83 ec 0c             	sub    $0xc,%esp
	return memmove(dst, src, n);
  80148a:	ff 75 10             	pushl  0x10(%ebp)
  80148d:	ff 75 0c             	pushl  0xc(%ebp)
  801490:	ff 75 08             	pushl  0x8(%ebp)
  801493:	e8 82 ff ff ff       	call   80141a <memmove>
}
  801498:	c9                   	leave  
  801499:	c3                   	ret    

0080149a <memcmp>:

int
memcmp(const void *v1, const void *v2, size_t n)
{
  80149a:	f3 0f 1e fb          	endbr32 
  80149e:	55                   	push   %ebp
  80149f:	89 e5                	mov    %esp,%ebp
  8014a1:	56                   	push   %esi
  8014a2:	53                   	push   %ebx
  8014a3:	8b 45 08             	mov    0x8(%ebp),%eax
  8014a6:	8b 55 0c             	mov    0xc(%ebp),%edx
  8014a9:	89 c6                	mov    %eax,%esi
  8014ab:	03 75 10             	add    0x10(%ebp),%esi
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  8014ae:	39 f0                	cmp    %esi,%eax
  8014b0:	74 1c                	je     8014ce <memcmp+0x34>
		if (*s1 != *s2)
  8014b2:	0f b6 08             	movzbl (%eax),%ecx
  8014b5:	0f b6 1a             	movzbl (%edx),%ebx
  8014b8:	38 d9                	cmp    %bl,%cl
  8014ba:	75 08                	jne    8014c4 <memcmp+0x2a>
			return (int) *s1 - (int) *s2;
		s1++, s2++;
  8014bc:	83 c0 01             	add    $0x1,%eax
  8014bf:	83 c2 01             	add    $0x1,%edx
  8014c2:	eb ea                	jmp    8014ae <memcmp+0x14>
			return (int) *s1 - (int) *s2;
  8014c4:	0f b6 c1             	movzbl %cl,%eax
  8014c7:	0f b6 db             	movzbl %bl,%ebx
  8014ca:	29 d8                	sub    %ebx,%eax
  8014cc:	eb 05                	jmp    8014d3 <memcmp+0x39>
	}

	return 0;
  8014ce:	b8 00 00 00 00       	mov    $0x0,%eax
}
  8014d3:	5b                   	pop    %ebx
  8014d4:	5e                   	pop    %esi
  8014d5:	5d                   	pop    %ebp
  8014d6:	c3                   	ret    

008014d7 <memfind>:

void *
memfind(const void *s, int c, size_t n)
{
  8014d7:	f3 0f 1e fb          	endbr32 
  8014db:	55                   	push   %ebp
  8014dc:	89 e5                	mov    %esp,%ebp
  8014de:	8b 45 08             	mov    0x8(%ebp),%eax
  8014e1:	8b 4d 0c             	mov    0xc(%ebp),%ecx
	const void *ends = (const char *) s + n;
  8014e4:	89 c2                	mov    %eax,%edx
  8014e6:	03 55 10             	add    0x10(%ebp),%edx
	for (; s < ends; s++)
  8014e9:	39 d0                	cmp    %edx,%eax
  8014eb:	73 09                	jae    8014f6 <memfind+0x1f>
		if (*(const unsigned char *) s == (unsigned char) c)
  8014ed:	38 08                	cmp    %cl,(%eax)
  8014ef:	74 05                	je     8014f6 <memfind+0x1f>
	for (; s < ends; s++)
  8014f1:	83 c0 01             	add    $0x1,%eax
  8014f4:	eb f3                	jmp    8014e9 <memfind+0x12>
			break;
	return (void *) s;
}
  8014f6:	5d                   	pop    %ebp
  8014f7:	c3                   	ret    

008014f8 <strtol>:

long
strtol(const char *s, char **endptr, int base)
{
  8014f8:	f3 0f 1e fb          	endbr32 
  8014fc:	55                   	push   %ebp
  8014fd:	89 e5                	mov    %esp,%ebp
  8014ff:	57                   	push   %edi
  801500:	56                   	push   %esi
  801501:	53                   	push   %ebx
  801502:	8b 4d 08             	mov    0x8(%ebp),%ecx
  801505:	8b 5d 10             	mov    0x10(%ebp),%ebx
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  801508:	eb 03                	jmp    80150d <strtol+0x15>
		s++;
  80150a:	83 c1 01             	add    $0x1,%ecx
	while (*s == ' ' || *s == '\t')
  80150d:	0f b6 01             	movzbl (%ecx),%eax
  801510:	3c 20                	cmp    $0x20,%al
  801512:	74 f6                	je     80150a <strtol+0x12>
  801514:	3c 09                	cmp    $0x9,%al
  801516:	74 f2                	je     80150a <strtol+0x12>

	// plus/minus sign
	if (*s == '+')
  801518:	3c 2b                	cmp    $0x2b,%al
  80151a:	74 2a                	je     801546 <strtol+0x4e>
	int neg = 0;
  80151c:	bf 00 00 00 00       	mov    $0x0,%edi
		s++;
	else if (*s == '-')
  801521:	3c 2d                	cmp    $0x2d,%al
  801523:	74 2b                	je     801550 <strtol+0x58>
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  801525:	f7 c3 ef ff ff ff    	test   $0xffffffef,%ebx
  80152b:	75 0f                	jne    80153c <strtol+0x44>
  80152d:	80 39 30             	cmpb   $0x30,(%ecx)
  801530:	74 28                	je     80155a <strtol+0x62>
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
		s++, base = 8;
	else if (base == 0)
		base = 10;
  801532:	85 db                	test   %ebx,%ebx
  801534:	b8 0a 00 00 00       	mov    $0xa,%eax
  801539:	0f 44 d8             	cmove  %eax,%ebx
  80153c:	b8 00 00 00 00       	mov    $0x0,%eax
  801541:	89 5d 10             	mov    %ebx,0x10(%ebp)
  801544:	eb 46                	jmp    80158c <strtol+0x94>
		s++;
  801546:	83 c1 01             	add    $0x1,%ecx
	int neg = 0;
  801549:	bf 00 00 00 00       	mov    $0x0,%edi
  80154e:	eb d5                	jmp    801525 <strtol+0x2d>
		s++, neg = 1;
  801550:	83 c1 01             	add    $0x1,%ecx
  801553:	bf 01 00 00 00       	mov    $0x1,%edi
  801558:	eb cb                	jmp    801525 <strtol+0x2d>
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  80155a:	80 79 01 78          	cmpb   $0x78,0x1(%ecx)
  80155e:	74 0e                	je     80156e <strtol+0x76>
	else if (base == 0 && s[0] == '0')
  801560:	85 db                	test   %ebx,%ebx
  801562:	75 d8                	jne    80153c <strtol+0x44>
		s++, base = 8;
  801564:	83 c1 01             	add    $0x1,%ecx
  801567:	bb 08 00 00 00       	mov    $0x8,%ebx
  80156c:	eb ce                	jmp    80153c <strtol+0x44>
		s += 2, base = 16;
  80156e:	83 c1 02             	add    $0x2,%ecx
  801571:	bb 10 00 00 00       	mov    $0x10,%ebx
  801576:	eb c4                	jmp    80153c <strtol+0x44>
	// digits
	while (1) {
		int dig;

		if (*s >= '0' && *s <= '9')
			dig = *s - '0';
  801578:	0f be d2             	movsbl %dl,%edx
  80157b:	83 ea 30             	sub    $0x30,%edx
			dig = *s - 'a' + 10;
		else if (*s >= 'A' && *s <= 'Z')
			dig = *s - 'A' + 10;
		else
			break;
		if (dig >= base)
  80157e:	3b 55 10             	cmp    0x10(%ebp),%edx
  801581:	7d 3a                	jge    8015bd <strtol+0xc5>
			break;
		s++, val = (val * base) + dig;
  801583:	83 c1 01             	add    $0x1,%ecx
  801586:	0f af 45 10          	imul   0x10(%ebp),%eax
  80158a:	01 d0                	add    %edx,%eax
		if (*s >= '0' && *s <= '9')
  80158c:	0f b6 11             	movzbl (%ecx),%edx
  80158f:	8d 72 d0             	lea    -0x30(%edx),%esi
  801592:	89 f3                	mov    %esi,%ebx
  801594:	80 fb 09             	cmp    $0x9,%bl
  801597:	76 df                	jbe    801578 <strtol+0x80>
		else if (*s >= 'a' && *s <= 'z')
  801599:	8d 72 9f             	lea    -0x61(%edx),%esi
  80159c:	89 f3                	mov    %esi,%ebx
  80159e:	80 fb 19             	cmp    $0x19,%bl
  8015a1:	77 08                	ja     8015ab <strtol+0xb3>
			dig = *s - 'a' + 10;
  8015a3:	0f be d2             	movsbl %dl,%edx
  8015a6:	83 ea 57             	sub    $0x57,%edx
  8015a9:	eb d3                	jmp    80157e <strtol+0x86>
		else if (*s >= 'A' && *s <= 'Z')
  8015ab:	8d 72 bf             	lea    -0x41(%edx),%esi
  8015ae:	89 f3                	mov    %esi,%ebx
  8015b0:	80 fb 19             	cmp    $0x19,%bl
  8015b3:	77 08                	ja     8015bd <strtol+0xc5>
			dig = *s - 'A' + 10;
  8015b5:	0f be d2             	movsbl %dl,%edx
  8015b8:	83 ea 37             	sub    $0x37,%edx
  8015bb:	eb c1                	jmp    80157e <strtol+0x86>
		// we don't properly detect overflow!
	}

	if (endptr)
  8015bd:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  8015c1:	74 05                	je     8015c8 <strtol+0xd0>
		*endptr = (char *) s;
  8015c3:	8b 75 0c             	mov    0xc(%ebp),%esi
  8015c6:	89 0e                	mov    %ecx,(%esi)
	return (neg ? -val : val);
  8015c8:	89 c2                	mov    %eax,%edx
  8015ca:	f7 da                	neg    %edx
  8015cc:	85 ff                	test   %edi,%edi
  8015ce:	0f 45 c2             	cmovne %edx,%eax
}
  8015d1:	5b                   	pop    %ebx
  8015d2:	5e                   	pop    %esi
  8015d3:	5f                   	pop    %edi
  8015d4:	5d                   	pop    %ebp
  8015d5:	c3                   	ret    

008015d6 <sys_cputs>:
	return ret;
}

void
sys_cputs(const char *s, size_t len)
{
  8015d6:	f3 0f 1e fb          	endbr32 
  8015da:	55                   	push   %ebp
  8015db:	89 e5                	mov    %esp,%ebp
  8015dd:	57                   	push   %edi
  8015de:	56                   	push   %esi
  8015df:	53                   	push   %ebx
	asm volatile("int %1\n"
  8015e0:	b8 00 00 00 00       	mov    $0x0,%eax
  8015e5:	8b 55 08             	mov    0x8(%ebp),%edx
  8015e8:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8015eb:	89 c3                	mov    %eax,%ebx
  8015ed:	89 c7                	mov    %eax,%edi
  8015ef:	89 c6                	mov    %eax,%esi
  8015f1:	cd 30                	int    $0x30
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}
  8015f3:	5b                   	pop    %ebx
  8015f4:	5e                   	pop    %esi
  8015f5:	5f                   	pop    %edi
  8015f6:	5d                   	pop    %ebp
  8015f7:	c3                   	ret    

008015f8 <sys_cgetc>:

int
sys_cgetc(void)
{
  8015f8:	f3 0f 1e fb          	endbr32 
  8015fc:	55                   	push   %ebp
  8015fd:	89 e5                	mov    %esp,%ebp
  8015ff:	57                   	push   %edi
  801600:	56                   	push   %esi
  801601:	53                   	push   %ebx
	asm volatile("int %1\n"
  801602:	ba 00 00 00 00       	mov    $0x0,%edx
  801607:	b8 01 00 00 00       	mov    $0x1,%eax
  80160c:	89 d1                	mov    %edx,%ecx
  80160e:	89 d3                	mov    %edx,%ebx
  801610:	89 d7                	mov    %edx,%edi
  801612:	89 d6                	mov    %edx,%esi
  801614:	cd 30                	int    $0x30
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}
  801616:	5b                   	pop    %ebx
  801617:	5e                   	pop    %esi
  801618:	5f                   	pop    %edi
  801619:	5d                   	pop    %ebp
  80161a:	c3                   	ret    

0080161b <sys_env_destroy>:

int
sys_env_destroy(envid_t envid)
{
  80161b:	f3 0f 1e fb          	endbr32 
  80161f:	55                   	push   %ebp
  801620:	89 e5                	mov    %esp,%ebp
  801622:	57                   	push   %edi
  801623:	56                   	push   %esi
  801624:	53                   	push   %ebx
  801625:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  801628:	b9 00 00 00 00       	mov    $0x0,%ecx
  80162d:	8b 55 08             	mov    0x8(%ebp),%edx
  801630:	b8 03 00 00 00       	mov    $0x3,%eax
  801635:	89 cb                	mov    %ecx,%ebx
  801637:	89 cf                	mov    %ecx,%edi
  801639:	89 ce                	mov    %ecx,%esi
  80163b:	cd 30                	int    $0x30
	if(check && ret > 0)
  80163d:	85 c0                	test   %eax,%eax
  80163f:	7f 08                	jg     801649 <sys_env_destroy+0x2e>
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}
  801641:	8d 65 f4             	lea    -0xc(%ebp),%esp
  801644:	5b                   	pop    %ebx
  801645:	5e                   	pop    %esi
  801646:	5f                   	pop    %edi
  801647:	5d                   	pop    %ebp
  801648:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  801649:	83 ec 0c             	sub    $0xc,%esp
  80164c:	50                   	push   %eax
  80164d:	6a 03                	push   $0x3
  80164f:	68 4f 3a 80 00       	push   $0x803a4f
  801654:	6a 23                	push   $0x23
  801656:	68 6c 3a 80 00       	push   $0x803a6c
  80165b:	e8 50 f4 ff ff       	call   800ab0 <_panic>

00801660 <sys_getenvid>:

envid_t
sys_getenvid(void)
{
  801660:	f3 0f 1e fb          	endbr32 
  801664:	55                   	push   %ebp
  801665:	89 e5                	mov    %esp,%ebp
  801667:	57                   	push   %edi
  801668:	56                   	push   %esi
  801669:	53                   	push   %ebx
	asm volatile("int %1\n"
  80166a:	ba 00 00 00 00       	mov    $0x0,%edx
  80166f:	b8 02 00 00 00       	mov    $0x2,%eax
  801674:	89 d1                	mov    %edx,%ecx
  801676:	89 d3                	mov    %edx,%ebx
  801678:	89 d7                	mov    %edx,%edi
  80167a:	89 d6                	mov    %edx,%esi
  80167c:	cd 30                	int    $0x30
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}
  80167e:	5b                   	pop    %ebx
  80167f:	5e                   	pop    %esi
  801680:	5f                   	pop    %edi
  801681:	5d                   	pop    %ebp
  801682:	c3                   	ret    

00801683 <sys_yield>:

void
sys_yield(void)
{
  801683:	f3 0f 1e fb          	endbr32 
  801687:	55                   	push   %ebp
  801688:	89 e5                	mov    %esp,%ebp
  80168a:	57                   	push   %edi
  80168b:	56                   	push   %esi
  80168c:	53                   	push   %ebx
	asm volatile("int %1\n"
  80168d:	ba 00 00 00 00       	mov    $0x0,%edx
  801692:	b8 0b 00 00 00       	mov    $0xb,%eax
  801697:	89 d1                	mov    %edx,%ecx
  801699:	89 d3                	mov    %edx,%ebx
  80169b:	89 d7                	mov    %edx,%edi
  80169d:	89 d6                	mov    %edx,%esi
  80169f:	cd 30                	int    $0x30
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}
  8016a1:	5b                   	pop    %ebx
  8016a2:	5e                   	pop    %esi
  8016a3:	5f                   	pop    %edi
  8016a4:	5d                   	pop    %ebp
  8016a5:	c3                   	ret    

008016a6 <sys_page_alloc>:

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
  8016a6:	f3 0f 1e fb          	endbr32 
  8016aa:	55                   	push   %ebp
  8016ab:	89 e5                	mov    %esp,%ebp
  8016ad:	57                   	push   %edi
  8016ae:	56                   	push   %esi
  8016af:	53                   	push   %ebx
  8016b0:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  8016b3:	be 00 00 00 00       	mov    $0x0,%esi
  8016b8:	8b 55 08             	mov    0x8(%ebp),%edx
  8016bb:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8016be:	b8 04 00 00 00       	mov    $0x4,%eax
  8016c3:	8b 5d 10             	mov    0x10(%ebp),%ebx
  8016c6:	89 f7                	mov    %esi,%edi
  8016c8:	cd 30                	int    $0x30
	if(check && ret > 0)
  8016ca:	85 c0                	test   %eax,%eax
  8016cc:	7f 08                	jg     8016d6 <sys_page_alloc+0x30>
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}
  8016ce:	8d 65 f4             	lea    -0xc(%ebp),%esp
  8016d1:	5b                   	pop    %ebx
  8016d2:	5e                   	pop    %esi
  8016d3:	5f                   	pop    %edi
  8016d4:	5d                   	pop    %ebp
  8016d5:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  8016d6:	83 ec 0c             	sub    $0xc,%esp
  8016d9:	50                   	push   %eax
  8016da:	6a 04                	push   $0x4
  8016dc:	68 4f 3a 80 00       	push   $0x803a4f
  8016e1:	6a 23                	push   $0x23
  8016e3:	68 6c 3a 80 00       	push   $0x803a6c
  8016e8:	e8 c3 f3 ff ff       	call   800ab0 <_panic>

008016ed <sys_page_map>:

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
  8016ed:	f3 0f 1e fb          	endbr32 
  8016f1:	55                   	push   %ebp
  8016f2:	89 e5                	mov    %esp,%ebp
  8016f4:	57                   	push   %edi
  8016f5:	56                   	push   %esi
  8016f6:	53                   	push   %ebx
  8016f7:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  8016fa:	8b 55 08             	mov    0x8(%ebp),%edx
  8016fd:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801700:	b8 05 00 00 00       	mov    $0x5,%eax
  801705:	8b 5d 10             	mov    0x10(%ebp),%ebx
  801708:	8b 7d 14             	mov    0x14(%ebp),%edi
  80170b:	8b 75 18             	mov    0x18(%ebp),%esi
  80170e:	cd 30                	int    $0x30
	if(check && ret > 0)
  801710:	85 c0                	test   %eax,%eax
  801712:	7f 08                	jg     80171c <sys_page_map+0x2f>
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}
  801714:	8d 65 f4             	lea    -0xc(%ebp),%esp
  801717:	5b                   	pop    %ebx
  801718:	5e                   	pop    %esi
  801719:	5f                   	pop    %edi
  80171a:	5d                   	pop    %ebp
  80171b:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  80171c:	83 ec 0c             	sub    $0xc,%esp
  80171f:	50                   	push   %eax
  801720:	6a 05                	push   $0x5
  801722:	68 4f 3a 80 00       	push   $0x803a4f
  801727:	6a 23                	push   $0x23
  801729:	68 6c 3a 80 00       	push   $0x803a6c
  80172e:	e8 7d f3 ff ff       	call   800ab0 <_panic>

00801733 <sys_page_unmap>:

int
sys_page_unmap(envid_t envid, void *va)
{
  801733:	f3 0f 1e fb          	endbr32 
  801737:	55                   	push   %ebp
  801738:	89 e5                	mov    %esp,%ebp
  80173a:	57                   	push   %edi
  80173b:	56                   	push   %esi
  80173c:	53                   	push   %ebx
  80173d:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  801740:	bb 00 00 00 00       	mov    $0x0,%ebx
  801745:	8b 55 08             	mov    0x8(%ebp),%edx
  801748:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  80174b:	b8 06 00 00 00       	mov    $0x6,%eax
  801750:	89 df                	mov    %ebx,%edi
  801752:	89 de                	mov    %ebx,%esi
  801754:	cd 30                	int    $0x30
	if(check && ret > 0)
  801756:	85 c0                	test   %eax,%eax
  801758:	7f 08                	jg     801762 <sys_page_unmap+0x2f>
	return syscall(SYS_page_unmap, 1, envid, (uint32_t) va, 0, 0, 0);
}
  80175a:	8d 65 f4             	lea    -0xc(%ebp),%esp
  80175d:	5b                   	pop    %ebx
  80175e:	5e                   	pop    %esi
  80175f:	5f                   	pop    %edi
  801760:	5d                   	pop    %ebp
  801761:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  801762:	83 ec 0c             	sub    $0xc,%esp
  801765:	50                   	push   %eax
  801766:	6a 06                	push   $0x6
  801768:	68 4f 3a 80 00       	push   $0x803a4f
  80176d:	6a 23                	push   $0x23
  80176f:	68 6c 3a 80 00       	push   $0x803a6c
  801774:	e8 37 f3 ff ff       	call   800ab0 <_panic>

00801779 <sys_env_set_status>:

// sys_exofork is inlined in lib.h

int
sys_env_set_status(envid_t envid, int status)
{
  801779:	f3 0f 1e fb          	endbr32 
  80177d:	55                   	push   %ebp
  80177e:	89 e5                	mov    %esp,%ebp
  801780:	57                   	push   %edi
  801781:	56                   	push   %esi
  801782:	53                   	push   %ebx
  801783:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  801786:	bb 00 00 00 00       	mov    $0x0,%ebx
  80178b:	8b 55 08             	mov    0x8(%ebp),%edx
  80178e:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801791:	b8 08 00 00 00       	mov    $0x8,%eax
  801796:	89 df                	mov    %ebx,%edi
  801798:	89 de                	mov    %ebx,%esi
  80179a:	cd 30                	int    $0x30
	if(check && ret > 0)
  80179c:	85 c0                	test   %eax,%eax
  80179e:	7f 08                	jg     8017a8 <sys_env_set_status+0x2f>
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}
  8017a0:	8d 65 f4             	lea    -0xc(%ebp),%esp
  8017a3:	5b                   	pop    %ebx
  8017a4:	5e                   	pop    %esi
  8017a5:	5f                   	pop    %edi
  8017a6:	5d                   	pop    %ebp
  8017a7:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  8017a8:	83 ec 0c             	sub    $0xc,%esp
  8017ab:	50                   	push   %eax
  8017ac:	6a 08                	push   $0x8
  8017ae:	68 4f 3a 80 00       	push   $0x803a4f
  8017b3:	6a 23                	push   $0x23
  8017b5:	68 6c 3a 80 00       	push   $0x803a6c
  8017ba:	e8 f1 f2 ff ff       	call   800ab0 <_panic>

008017bf <sys_env_set_trapframe>:

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
  8017bf:	f3 0f 1e fb          	endbr32 
  8017c3:	55                   	push   %ebp
  8017c4:	89 e5                	mov    %esp,%ebp
  8017c6:	57                   	push   %edi
  8017c7:	56                   	push   %esi
  8017c8:	53                   	push   %ebx
  8017c9:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  8017cc:	bb 00 00 00 00       	mov    $0x0,%ebx
  8017d1:	8b 55 08             	mov    0x8(%ebp),%edx
  8017d4:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8017d7:	b8 09 00 00 00       	mov    $0x9,%eax
  8017dc:	89 df                	mov    %ebx,%edi
  8017de:	89 de                	mov    %ebx,%esi
  8017e0:	cd 30                	int    $0x30
	if(check && ret > 0)
  8017e2:	85 c0                	test   %eax,%eax
  8017e4:	7f 08                	jg     8017ee <sys_env_set_trapframe+0x2f>
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}
  8017e6:	8d 65 f4             	lea    -0xc(%ebp),%esp
  8017e9:	5b                   	pop    %ebx
  8017ea:	5e                   	pop    %esi
  8017eb:	5f                   	pop    %edi
  8017ec:	5d                   	pop    %ebp
  8017ed:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  8017ee:	83 ec 0c             	sub    $0xc,%esp
  8017f1:	50                   	push   %eax
  8017f2:	6a 09                	push   $0x9
  8017f4:	68 4f 3a 80 00       	push   $0x803a4f
  8017f9:	6a 23                	push   $0x23
  8017fb:	68 6c 3a 80 00       	push   $0x803a6c
  801800:	e8 ab f2 ff ff       	call   800ab0 <_panic>

00801805 <sys_env_set_pgfault_upcall>:

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
  801805:	f3 0f 1e fb          	endbr32 
  801809:	55                   	push   %ebp
  80180a:	89 e5                	mov    %esp,%ebp
  80180c:	57                   	push   %edi
  80180d:	56                   	push   %esi
  80180e:	53                   	push   %ebx
  80180f:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  801812:	bb 00 00 00 00       	mov    $0x0,%ebx
  801817:	8b 55 08             	mov    0x8(%ebp),%edx
  80181a:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  80181d:	b8 0a 00 00 00       	mov    $0xa,%eax
  801822:	89 df                	mov    %ebx,%edi
  801824:	89 de                	mov    %ebx,%esi
  801826:	cd 30                	int    $0x30
	if(check && ret > 0)
  801828:	85 c0                	test   %eax,%eax
  80182a:	7f 08                	jg     801834 <sys_env_set_pgfault_upcall+0x2f>
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}
  80182c:	8d 65 f4             	lea    -0xc(%ebp),%esp
  80182f:	5b                   	pop    %ebx
  801830:	5e                   	pop    %esi
  801831:	5f                   	pop    %edi
  801832:	5d                   	pop    %ebp
  801833:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  801834:	83 ec 0c             	sub    $0xc,%esp
  801837:	50                   	push   %eax
  801838:	6a 0a                	push   $0xa
  80183a:	68 4f 3a 80 00       	push   $0x803a4f
  80183f:	6a 23                	push   $0x23
  801841:	68 6c 3a 80 00       	push   $0x803a6c
  801846:	e8 65 f2 ff ff       	call   800ab0 <_panic>

0080184b <sys_ipc_try_send>:

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
  80184b:	f3 0f 1e fb          	endbr32 
  80184f:	55                   	push   %ebp
  801850:	89 e5                	mov    %esp,%ebp
  801852:	57                   	push   %edi
  801853:	56                   	push   %esi
  801854:	53                   	push   %ebx
	asm volatile("int %1\n"
  801855:	8b 55 08             	mov    0x8(%ebp),%edx
  801858:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  80185b:	b8 0c 00 00 00       	mov    $0xc,%eax
  801860:	be 00 00 00 00       	mov    $0x0,%esi
  801865:	8b 5d 10             	mov    0x10(%ebp),%ebx
  801868:	8b 7d 14             	mov    0x14(%ebp),%edi
  80186b:	cd 30                	int    $0x30
	return syscall(SYS_ipc_try_send, 0, envid, value, (uint32_t) srcva, perm, 0);
}
  80186d:	5b                   	pop    %ebx
  80186e:	5e                   	pop    %esi
  80186f:	5f                   	pop    %edi
  801870:	5d                   	pop    %ebp
  801871:	c3                   	ret    

00801872 <sys_ipc_recv>:

int
sys_ipc_recv(void *dstva)
{
  801872:	f3 0f 1e fb          	endbr32 
  801876:	55                   	push   %ebp
  801877:	89 e5                	mov    %esp,%ebp
  801879:	57                   	push   %edi
  80187a:	56                   	push   %esi
  80187b:	53                   	push   %ebx
  80187c:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  80187f:	b9 00 00 00 00       	mov    $0x0,%ecx
  801884:	8b 55 08             	mov    0x8(%ebp),%edx
  801887:	b8 0d 00 00 00       	mov    $0xd,%eax
  80188c:	89 cb                	mov    %ecx,%ebx
  80188e:	89 cf                	mov    %ecx,%edi
  801890:	89 ce                	mov    %ecx,%esi
  801892:	cd 30                	int    $0x30
	if(check && ret > 0)
  801894:	85 c0                	test   %eax,%eax
  801896:	7f 08                	jg     8018a0 <sys_ipc_recv+0x2e>
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}
  801898:	8d 65 f4             	lea    -0xc(%ebp),%esp
  80189b:	5b                   	pop    %ebx
  80189c:	5e                   	pop    %esi
  80189d:	5f                   	pop    %edi
  80189e:	5d                   	pop    %ebp
  80189f:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  8018a0:	83 ec 0c             	sub    $0xc,%esp
  8018a3:	50                   	push   %eax
  8018a4:	6a 0d                	push   $0xd
  8018a6:	68 4f 3a 80 00       	push   $0x803a4f
  8018ab:	6a 23                	push   $0x23
  8018ad:	68 6c 3a 80 00       	push   $0x803a6c
  8018b2:	e8 f9 f1 ff ff       	call   800ab0 <_panic>

008018b7 <pgfault>:
// Custom page fault handler - if faulting page is copy-on-write,
// map in our own private writable copy.
//
static void
pgfault(struct UTrapframe *utf)
{
  8018b7:	f3 0f 1e fb          	endbr32 
  8018bb:	55                   	push   %ebp
  8018bc:	89 e5                	mov    %esp,%ebp
  8018be:	56                   	push   %esi
  8018bf:	53                   	push   %ebx
  8018c0:	8b 45 08             	mov    0x8(%ebp),%eax
	void *addr = (void *) utf->utf_fault_va;
  8018c3:	8b 18                	mov    (%eax),%ebx
	/*
	将父进程空间中所有可以写的页表的部分全部标记为可读且COW【因此读取的时候不会进入pgfault，但是写的时候会触发pgfault】。
	而当父进程或者子进程任意一个发生了写的时候，因为页表现在都是不可写的，所以会触发异常，进入到我们设定的page fault处理例程，
	当检测到是对COW页的写操作的情况下，就可以将要写入的页的内容全部拷贝一份，重新映射。
	*/
    if (!((err & FEC_WR) && (uvpd[PDX(addr)] & PTE_P) && 
  8018c5:	f6 40 04 02          	testb  $0x2,0x4(%eax)
  8018c9:	0f 84 b2 00 00 00    	je     801981 <pgfault+0xca>
  8018cf:	89 d8                	mov    %ebx,%eax
  8018d1:	c1 e8 16             	shr    $0x16,%eax
  8018d4:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  8018db:	a8 01                	test   $0x1,%al
  8018dd:	0f 84 9e 00 00 00    	je     801981 <pgfault+0xca>
			(uvpt[PGNUM(addr)] & PTE_P) && (uvpt[PGNUM(addr)] & PTE_COW)))
  8018e3:	89 d8                	mov    %ebx,%eax
  8018e5:	c1 e8 0c             	shr    $0xc,%eax
  8018e8:	8b 14 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%edx
    if (!((err & FEC_WR) && (uvpd[PDX(addr)] & PTE_P) && 
  8018ef:	f6 c2 01             	test   $0x1,%dl
  8018f2:	0f 84 89 00 00 00    	je     801981 <pgfault+0xca>
			(uvpt[PGNUM(addr)] & PTE_P) && (uvpt[PGNUM(addr)] & PTE_COW)))
  8018f8:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
    if (!((err & FEC_WR) && (uvpd[PDX(addr)] & PTE_P) && 
  8018ff:	f6 c4 08             	test   $0x8,%ah
  801902:	74 7d                	je     801981 <pgfault+0xca>
                panic("pgfault: it's not writable or attempt to access a non-cow page!");
	//为该进程分配新的页面。
	envid_t envid=sys_getenvid();
  801904:	e8 57 fd ff ff       	call   801660 <sys_getenvid>
  801909:	89 c6                	mov    %eax,%esi
	r=sys_page_alloc(envid,(void*)PFTEMP,PTE_P|PTE_U|PTE_W);
  80190b:	83 ec 04             	sub    $0x4,%esp
  80190e:	6a 07                	push   $0x7
  801910:	68 00 f0 7f 00       	push   $0x7ff000
  801915:	50                   	push   %eax
  801916:	e8 8b fd ff ff       	call   8016a6 <sys_page_alloc>
	if(r<0){
  80191b:	83 c4 10             	add    $0x10,%esp
  80191e:	85 c0                	test   %eax,%eax
  801920:	78 73                	js     801995 <pgfault+0xde>
		 panic("pgfault: page allocation failed %e", r);
	}
	//解开了我的疑惑，为什么随着fork页空间会逐渐发生偏移。
	//迁移数据过去。
	addr=ROUNDDOWN(addr,PGSIZE);
  801922:	81 e3 00 f0 ff ff    	and    $0xfffff000,%ebx
	//拷贝内容。
	memmove(PFTEMP,addr,PGSIZE);
  801928:	83 ec 04             	sub    $0x4,%esp
  80192b:	68 00 10 00 00       	push   $0x1000
  801930:	53                   	push   %ebx
  801931:	68 00 f0 7f 00       	push   $0x7ff000
  801936:	e8 df fa ff ff       	call   80141a <memmove>
	//解除和addr的映射关系。
	r=sys_page_unmap(envid,(void*)addr);
  80193b:	83 c4 08             	add    $0x8,%esp
  80193e:	53                   	push   %ebx
  80193f:	56                   	push   %esi
  801940:	e8 ee fd ff ff       	call   801733 <sys_page_unmap>
	if(r<0)
  801945:	83 c4 10             	add    $0x10,%esp
  801948:	85 c0                	test   %eax,%eax
  80194a:	78 5b                	js     8019a7 <pgfault+0xf0>
	panic("pgfault: page unmap failed %e", r);
	r=sys_page_map(envid,PFTEMP,envid,addr,PTE_P|PTE_U|PTE_W);
  80194c:	83 ec 0c             	sub    $0xc,%esp
  80194f:	6a 07                	push   $0x7
  801951:	53                   	push   %ebx
  801952:	56                   	push   %esi
  801953:	68 00 f0 7f 00       	push   $0x7ff000
  801958:	56                   	push   %esi
  801959:	e8 8f fd ff ff       	call   8016ed <sys_page_map>
	if(r<0)
  80195e:	83 c4 20             	add    $0x20,%esp
  801961:	85 c0                	test   %eax,%eax
  801963:	78 54                	js     8019b9 <pgfault+0x102>
	panic("pgfault: page map failed %e", r);
	r=sys_page_unmap(envid,PFTEMP);
  801965:	83 ec 08             	sub    $0x8,%esp
  801968:	68 00 f0 7f 00       	push   $0x7ff000
  80196d:	56                   	push   %esi
  80196e:	e8 c0 fd ff ff       	call   801733 <sys_page_unmap>
	if(r<0)
  801973:	83 c4 10             	add    $0x10,%esp
  801976:	85 c0                	test   %eax,%eax
  801978:	78 51                	js     8019cb <pgfault+0x114>
	panic("pgfault: page unmap failed %e", r);
}
  80197a:	8d 65 f8             	lea    -0x8(%ebp),%esp
  80197d:	5b                   	pop    %ebx
  80197e:	5e                   	pop    %esi
  80197f:	5d                   	pop    %ebp
  801980:	c3                   	ret    
                panic("pgfault: it's not writable or attempt to access a non-cow page!");
  801981:	83 ec 04             	sub    $0x4,%esp
  801984:	68 7c 3a 80 00       	push   $0x803a7c
  801989:	6a 2c                	push   $0x2c
  80198b:	68 2b 3b 80 00       	push   $0x803b2b
  801990:	e8 1b f1 ff ff       	call   800ab0 <_panic>
		 panic("pgfault: page allocation failed %e", r);
  801995:	50                   	push   %eax
  801996:	68 bc 3a 80 00       	push   $0x803abc
  80199b:	6a 31                	push   $0x31
  80199d:	68 2b 3b 80 00       	push   $0x803b2b
  8019a2:	e8 09 f1 ff ff       	call   800ab0 <_panic>
	panic("pgfault: page unmap failed %e", r);
  8019a7:	50                   	push   %eax
  8019a8:	68 36 3b 80 00       	push   $0x803b36
  8019ad:	6a 3b                	push   $0x3b
  8019af:	68 2b 3b 80 00       	push   $0x803b2b
  8019b4:	e8 f7 f0 ff ff       	call   800ab0 <_panic>
	panic("pgfault: page map failed %e", r);
  8019b9:	50                   	push   %eax
  8019ba:	68 54 3b 80 00       	push   $0x803b54
  8019bf:	6a 3e                	push   $0x3e
  8019c1:	68 2b 3b 80 00       	push   $0x803b2b
  8019c6:	e8 e5 f0 ff ff       	call   800ab0 <_panic>
	panic("pgfault: page unmap failed %e", r);
  8019cb:	50                   	push   %eax
  8019cc:	68 36 3b 80 00       	push   $0x803b36
  8019d1:	6a 41                	push   $0x41
  8019d3:	68 2b 3b 80 00       	push   $0x803b2b
  8019d8:	e8 d3 f0 ff ff       	call   800ab0 <_panic>

008019dd <fork>:
//   Neither user exception stack should ever be marked copy-on-write,
//   so you must allocate a new page for the child's user exception stack.
//
envid_t
fork(void)
{
  8019dd:	f3 0f 1e fb          	endbr32 
  8019e1:	55                   	push   %ebp
  8019e2:	89 e5                	mov    %esp,%ebp
  8019e4:	57                   	push   %edi
  8019e5:	56                   	push   %esi
  8019e6:	53                   	push   %ebx
  8019e7:	83 ec 28             	sub    $0x28,%esp
	// LAB 4: Your code here.
	envid_t envid;
	uintptr_t pageVa;
	unsigned pn;
	//设置pgfault情况下对应处理的函数。
	set_pgfault_handler(pgfault);
  8019ea:	68 b7 18 80 00       	push   $0x8018b7
  8019ef:	e8 96 16 00 00       	call   80308a <set_pgfault_handler>
// This must be inlined.  Exercise for reader: why?
static inline envid_t __attribute__((always_inline))
sys_exofork(void)
{
	envid_t ret;
	asm volatile("int %2"
  8019f4:	b8 07 00 00 00       	mov    $0x7,%eax
  8019f9:	cd 30                	int    $0x30
  8019fb:	89 c7                	mov    %eax,%edi
  8019fd:	89 45 e4             	mov    %eax,-0x1c(%ebp)
	//首先需要分配一个env，env_alloc是内核态调用的，因此只能去调系统调用对应的函数来请求分配一个环境描述符。
	envid=sys_exofork();
	//分配成功
	if(envid>0){
  801a00:	83 c4 10             	add    $0x10,%esp
  801a03:	85 c0                	test   %eax,%eax
  801a05:	0f 8e 9d 01 00 00    	jle    801ba8 <fork+0x1cb>
		//接下来应该要拷贝父进程。当然这里让我吃惊的是直接可以调用对应的宏并且并没有去请求父进程。jos系统似乎是把所有的子进程都来源于同一进程，而不是父子继承关系。
		for(pageVa=UTEXT;pageVa<USTACKTOP;pageVa+=PGSIZE){
  801a0b:	bb 00 00 80 00       	mov    $0x800000,%ebx
  801a10:	eb 5b                	jmp    801a6d <fork+0x90>
			sys_page_map(0, addr, envid, addr, PTE_SYSCALL);
  801a12:	83 ec 0c             	sub    $0xc,%esp
  801a15:	68 07 0e 00 00       	push   $0xe07
  801a1a:	56                   	push   %esi
  801a1b:	ff 75 e4             	pushl  -0x1c(%ebp)
  801a1e:	56                   	push   %esi
  801a1f:	6a 00                	push   $0x0
  801a21:	e8 c7 fc ff ff       	call   8016ed <sys_page_map>
  801a26:	83 c4 20             	add    $0x20,%esp
  801a29:	eb 30                	jmp    801a5b <fork+0x7e>
                panic("duppage: sys_page_map fail\n");
  801a2b:	83 ec 04             	sub    $0x4,%esp
  801a2e:	68 70 3b 80 00       	push   $0x803b70
  801a33:	6a 63                	push   $0x63
  801a35:	68 2b 3b 80 00       	push   $0x803b2b
  801a3a:	e8 71 f0 ff ff       	call   800ab0 <_panic>
            r = sys_page_map(0, addr, envid, addr, PTE_U | PTE_P);
  801a3f:	83 ec 0c             	sub    $0xc,%esp
  801a42:	6a 05                	push   $0x5
  801a44:	56                   	push   %esi
  801a45:	ff 75 e4             	pushl  -0x1c(%ebp)
  801a48:	56                   	push   %esi
  801a49:	6a 00                	push   $0x0
  801a4b:	e8 9d fc ff ff       	call   8016ed <sys_page_map>
            if(r < 0)
  801a50:	83 c4 20             	add    $0x20,%esp
  801a53:	85 c0                	test   %eax,%eax
  801a55:	0f 88 ac 00 00 00    	js     801b07 <fork+0x12a>
		for(pageVa=UTEXT;pageVa<USTACKTOP;pageVa+=PGSIZE){
  801a5b:	81 c3 00 10 00 00    	add    $0x1000,%ebx
  801a61:	81 fb 00 e0 bf ee    	cmp    $0xeebfe000,%ebx
  801a67:	0f 84 ae 00 00 00    	je     801b1b <fork+0x13e>
			pn=PGNUM(pageVa);
			//检查权限，挨个copy页
			if((uvpd[PDX(pageVa)]&PTE_P)&&(uvpt[pn]&PTE_P)&&(uvpt[pn]&PTE_U)){
  801a6d:	89 d8                	mov    %ebx,%eax
  801a6f:	c1 e8 16             	shr    $0x16,%eax
  801a72:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  801a79:	a8 01                	test   $0x1,%al
  801a7b:	74 de                	je     801a5b <fork+0x7e>
			pn=PGNUM(pageVa);
  801a7d:	89 d8                	mov    %ebx,%eax
  801a7f:	c1 e8 0c             	shr    $0xc,%eax
			if((uvpd[PDX(pageVa)]&PTE_P)&&(uvpt[pn]&PTE_P)&&(uvpt[pn]&PTE_U)){
  801a82:	8b 14 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%edx
  801a89:	f6 c2 01             	test   $0x1,%dl
  801a8c:	74 cd                	je     801a5b <fork+0x7e>
  801a8e:	8b 14 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%edx
  801a95:	f6 c2 04             	test   $0x4,%dl
  801a98:	74 c1                	je     801a5b <fork+0x7e>
        addr = (void *)((uint32_t)pn * PGSIZE);
  801a9a:	89 c6                	mov    %eax,%esi
  801a9c:	c1 e6 0c             	shl    $0xc,%esi
        pte = uvpt[pn];
  801a9f:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
		if(pte&PTE_SHARE){
  801aa6:	f6 c4 04             	test   $0x4,%ah
  801aa9:	0f 85 63 ff ff ff    	jne    801a12 <fork+0x35>
        else if((pte & PTE_COW) || (pte & PTE_W))
  801aaf:	a9 02 08 00 00       	test   $0x802,%eax
  801ab4:	74 89                	je     801a3f <fork+0x62>
            r = sys_page_map(0, addr, envid, addr, PTE_COW | PTE_U | PTE_P);
  801ab6:	83 ec 0c             	sub    $0xc,%esp
  801ab9:	68 05 08 00 00       	push   $0x805
  801abe:	56                   	push   %esi
  801abf:	ff 75 e4             	pushl  -0x1c(%ebp)
  801ac2:	56                   	push   %esi
  801ac3:	6a 00                	push   $0x0
  801ac5:	e8 23 fc ff ff       	call   8016ed <sys_page_map>
            if(r < 0)
  801aca:	83 c4 20             	add    $0x20,%esp
  801acd:	85 c0                	test   %eax,%eax
  801acf:	0f 88 56 ff ff ff    	js     801a2b <fork+0x4e>
            r = sys_page_map(0, addr, 0, addr, PTE_COW | PTE_U | PTE_P);
  801ad5:	83 ec 0c             	sub    $0xc,%esp
  801ad8:	68 05 08 00 00       	push   $0x805
  801add:	56                   	push   %esi
  801ade:	6a 00                	push   $0x0
  801ae0:	56                   	push   %esi
  801ae1:	6a 00                	push   $0x0
  801ae3:	e8 05 fc ff ff       	call   8016ed <sys_page_map>
            if(r < 0)
  801ae8:	83 c4 20             	add    $0x20,%esp
  801aeb:	85 c0                	test   %eax,%eax
  801aed:	0f 89 68 ff ff ff    	jns    801a5b <fork+0x7e>
                panic("duppage: sys_page_map fail\n");
  801af3:	83 ec 04             	sub    $0x4,%esp
  801af6:	68 70 3b 80 00       	push   $0x803b70
  801afb:	6a 66                	push   $0x66
  801afd:	68 2b 3b 80 00       	push   $0x803b2b
  801b02:	e8 a9 ef ff ff       	call   800ab0 <_panic>
                panic("duppage: sys_page_map fail\n");
  801b07:	83 ec 04             	sub    $0x4,%esp
  801b0a:	68 70 3b 80 00       	push   $0x803b70
  801b0f:	6a 6c                	push   $0x6c
  801b11:	68 2b 3b 80 00       	push   $0x803b2b
  801b16:	e8 95 ef ff ff       	call   800ab0 <_panic>
				duppage(envid,pn);}
			}
		//分配异常栈。
		int32_t flag=sys_page_alloc(envid,(void*)(UXSTACKTOP-PGSIZE),PTE_P|PTE_U|PTE_W);
  801b1b:	83 ec 04             	sub    $0x4,%esp
  801b1e:	6a 07                	push   $0x7
  801b20:	68 00 f0 bf ee       	push   $0xeebff000
  801b25:	57                   	push   %edi
  801b26:	e8 7b fb ff ff       	call   8016a6 <sys_page_alloc>
		if(flag<0){
  801b2b:	83 c4 10             	add    $0x10,%esp
  801b2e:	85 c0                	test   %eax,%eax
  801b30:	78 31                	js     801b63 <fork+0x186>
			panic("panic by alloc page");
		}
		//设置对应的异常处理函数。
		extern void _pgfault_upcall(void);
		flag=sys_env_set_pgfault_upcall(envid,_pgfault_upcall);
  801b32:	83 ec 08             	sub    $0x8,%esp
  801b35:	68 04 31 80 00       	push   $0x803104
  801b3a:	57                   	push   %edi
  801b3b:	e8 c5 fc ff ff       	call   801805 <sys_env_set_pgfault_upcall>
		if(flag<0){
  801b40:	83 c4 10             	add    $0x10,%esp
  801b43:	85 c0                	test   %eax,%eax
  801b45:	78 33                	js     801b7a <fork+0x19d>
			panic("panic by set pgfault upcall faction");
		}
		//设置子进程，等待调度。
		flag=sys_env_set_status(envid,ENV_RUNNABLE);
  801b47:	83 ec 08             	sub    $0x8,%esp
  801b4a:	6a 02                	push   $0x2
  801b4c:	57                   	push   %edi
  801b4d:	e8 27 fc ff ff       	call   801779 <sys_env_set_status>
		if(flag<0){
  801b52:	83 c4 10             	add    $0x10,%esp
  801b55:	85 c0                	test   %eax,%eax
  801b57:	78 38                	js     801b91 <fork+0x1b4>
		//否则报错。
		panic("panic by alloc envid");
	}

	
}
  801b59:	89 f8                	mov    %edi,%eax
  801b5b:	8d 65 f4             	lea    -0xc(%ebp),%esp
  801b5e:	5b                   	pop    %ebx
  801b5f:	5e                   	pop    %esi
  801b60:	5f                   	pop    %edi
  801b61:	5d                   	pop    %ebp
  801b62:	c3                   	ret    
			panic("panic by alloc page");
  801b63:	83 ec 04             	sub    $0x4,%esp
  801b66:	68 8c 3b 80 00       	push   $0x803b8c
  801b6b:	68 98 00 00 00       	push   $0x98
  801b70:	68 2b 3b 80 00       	push   $0x803b2b
  801b75:	e8 36 ef ff ff       	call   800ab0 <_panic>
			panic("panic by set pgfault upcall faction");
  801b7a:	83 ec 04             	sub    $0x4,%esp
  801b7d:	68 e0 3a 80 00       	push   $0x803ae0
  801b82:	68 9e 00 00 00       	push   $0x9e
  801b87:	68 2b 3b 80 00       	push   $0x803b2b
  801b8c:	e8 1f ef ff ff       	call   800ab0 <_panic>
			panic("panic by set env status to ENV_RUNABLE");
  801b91:	83 ec 04             	sub    $0x4,%esp
  801b94:	68 04 3b 80 00       	push   $0x803b04
  801b99:	68 a3 00 00 00       	push   $0xa3
  801b9e:	68 2b 3b 80 00       	push   $0x803b2b
  801ba3:	e8 08 ef ff ff       	call   800ab0 <_panic>
	else if(envid==0){
  801ba8:	75 19                	jne    801bc3 <fork+0x1e6>
        thisenv = &envs[ENVX(sys_getenvid())];	//在子进程中设置thisenv为自己
  801baa:	e8 b1 fa ff ff       	call   801660 <sys_getenvid>
  801baf:	25 ff 03 00 00       	and    $0x3ff,%eax
  801bb4:	6b c0 7c             	imul   $0x7c,%eax,%eax
  801bb7:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  801bbc:	a3 24 54 80 00       	mov    %eax,0x805424
		return 0;
  801bc1:	eb 96                	jmp    801b59 <fork+0x17c>
		panic("panic by alloc envid");
  801bc3:	83 ec 04             	sub    $0x4,%esp
  801bc6:	68 a0 3b 80 00       	push   $0x803ba0
  801bcb:	68 ad 00 00 00       	push   $0xad
  801bd0:	68 2b 3b 80 00       	push   $0x803b2b
  801bd5:	e8 d6 ee ff ff       	call   800ab0 <_panic>

00801bda <sfork>:

// Challenge!
int
sfork(void)
{
  801bda:	f3 0f 1e fb          	endbr32 
  801bde:	55                   	push   %ebp
  801bdf:	89 e5                	mov    %esp,%ebp
  801be1:	83 ec 0c             	sub    $0xc,%esp
	panic("sfork not implemented");
  801be4:	68 b5 3b 80 00       	push   $0x803bb5
  801be9:	68 b7 00 00 00       	push   $0xb7
  801bee:	68 2b 3b 80 00       	push   $0x803b2b
  801bf3:	e8 b8 ee ff ff       	call   800ab0 <_panic>

00801bf8 <argstart>:
#include <inc/args.h>
#include <inc/string.h>

void
argstart(int *argc, char **argv, struct Argstate *args)
{
  801bf8:	f3 0f 1e fb          	endbr32 
  801bfc:	55                   	push   %ebp
  801bfd:	89 e5                	mov    %esp,%ebp
  801bff:	8b 55 08             	mov    0x8(%ebp),%edx
  801c02:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801c05:	8b 45 10             	mov    0x10(%ebp),%eax
	args->argc = argc;
  801c08:	89 10                	mov    %edx,(%eax)
	args->argv = (const char **) argv;
  801c0a:	89 48 04             	mov    %ecx,0x4(%eax)
	args->curarg = (*argc > 1 && argv ? "" : 0);
  801c0d:	83 3a 01             	cmpl   $0x1,(%edx)
  801c10:	7e 09                	jle    801c1b <argstart+0x23>
  801c12:	ba 21 35 80 00       	mov    $0x803521,%edx
  801c17:	85 c9                	test   %ecx,%ecx
  801c19:	75 05                	jne    801c20 <argstart+0x28>
  801c1b:	ba 00 00 00 00       	mov    $0x0,%edx
  801c20:	89 50 08             	mov    %edx,0x8(%eax)
	args->argvalue = 0;
  801c23:	c7 40 0c 00 00 00 00 	movl   $0x0,0xc(%eax)
}
  801c2a:	5d                   	pop    %ebp
  801c2b:	c3                   	ret    

00801c2c <argnext>:

int
argnext(struct Argstate *args)
{
  801c2c:	f3 0f 1e fb          	endbr32 
  801c30:	55                   	push   %ebp
  801c31:	89 e5                	mov    %esp,%ebp
  801c33:	53                   	push   %ebx
  801c34:	83 ec 04             	sub    $0x4,%esp
  801c37:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int arg;

	args->argvalue = 0;
  801c3a:	c7 43 0c 00 00 00 00 	movl   $0x0,0xc(%ebx)

	// Done processing arguments if args->curarg == 0
	if (args->curarg == 0)
  801c41:	8b 43 08             	mov    0x8(%ebx),%eax
  801c44:	85 c0                	test   %eax,%eax
  801c46:	74 74                	je     801cbc <argnext+0x90>
		return -1;

	if (!*args->curarg) {
  801c48:	80 38 00             	cmpb   $0x0,(%eax)
  801c4b:	75 48                	jne    801c95 <argnext+0x69>
		// Need to process the next argument
		// Check for end of argument list
		if (*args->argc == 1
  801c4d:	8b 0b                	mov    (%ebx),%ecx
  801c4f:	83 39 01             	cmpl   $0x1,(%ecx)
  801c52:	74 5a                	je     801cae <argnext+0x82>
		    || args->argv[1][0] != '-'
  801c54:	8b 53 04             	mov    0x4(%ebx),%edx
  801c57:	8b 42 04             	mov    0x4(%edx),%eax
  801c5a:	80 38 2d             	cmpb   $0x2d,(%eax)
  801c5d:	75 4f                	jne    801cae <argnext+0x82>
		    || args->argv[1][1] == '\0')
  801c5f:	80 78 01 00          	cmpb   $0x0,0x1(%eax)
  801c63:	74 49                	je     801cae <argnext+0x82>
			goto endofargs;
		// Shift arguments down one
		args->curarg = args->argv[1] + 1;
  801c65:	83 c0 01             	add    $0x1,%eax
  801c68:	89 43 08             	mov    %eax,0x8(%ebx)
		memmove(args->argv + 1, args->argv + 2, sizeof(const char *) * (*args->argc - 1));
  801c6b:	83 ec 04             	sub    $0x4,%esp
  801c6e:	8b 01                	mov    (%ecx),%eax
  801c70:	8d 04 85 fc ff ff ff 	lea    -0x4(,%eax,4),%eax
  801c77:	50                   	push   %eax
  801c78:	8d 42 08             	lea    0x8(%edx),%eax
  801c7b:	50                   	push   %eax
  801c7c:	83 c2 04             	add    $0x4,%edx
  801c7f:	52                   	push   %edx
  801c80:	e8 95 f7 ff ff       	call   80141a <memmove>
		(*args->argc)--;
  801c85:	8b 03                	mov    (%ebx),%eax
  801c87:	83 28 01             	subl   $0x1,(%eax)
		// Check for "--": end of argument list
		if (args->curarg[0] == '-' && args->curarg[1] == '\0')
  801c8a:	8b 43 08             	mov    0x8(%ebx),%eax
  801c8d:	83 c4 10             	add    $0x10,%esp
  801c90:	80 38 2d             	cmpb   $0x2d,(%eax)
  801c93:	74 13                	je     801ca8 <argnext+0x7c>
			goto endofargs;
	}

	arg = (unsigned char) *args->curarg;
  801c95:	8b 43 08             	mov    0x8(%ebx),%eax
  801c98:	0f b6 10             	movzbl (%eax),%edx
	args->curarg++;
  801c9b:	83 c0 01             	add    $0x1,%eax
  801c9e:	89 43 08             	mov    %eax,0x8(%ebx)
	return arg;

    endofargs:
	args->curarg = 0;
	return -1;
}
  801ca1:	89 d0                	mov    %edx,%eax
  801ca3:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  801ca6:	c9                   	leave  
  801ca7:	c3                   	ret    
		if (args->curarg[0] == '-' && args->curarg[1] == '\0')
  801ca8:	80 78 01 00          	cmpb   $0x0,0x1(%eax)
  801cac:	75 e7                	jne    801c95 <argnext+0x69>
	args->curarg = 0;
  801cae:	c7 43 08 00 00 00 00 	movl   $0x0,0x8(%ebx)
	return -1;
  801cb5:	ba ff ff ff ff       	mov    $0xffffffff,%edx
  801cba:	eb e5                	jmp    801ca1 <argnext+0x75>
		return -1;
  801cbc:	ba ff ff ff ff       	mov    $0xffffffff,%edx
  801cc1:	eb de                	jmp    801ca1 <argnext+0x75>

00801cc3 <argnextvalue>:
	return (char*) (args->argvalue ? args->argvalue : argnextvalue(args));
}

char *
argnextvalue(struct Argstate *args)
{
  801cc3:	f3 0f 1e fb          	endbr32 
  801cc7:	55                   	push   %ebp
  801cc8:	89 e5                	mov    %esp,%ebp
  801cca:	53                   	push   %ebx
  801ccb:	83 ec 04             	sub    $0x4,%esp
  801cce:	8b 5d 08             	mov    0x8(%ebp),%ebx
	if (!args->curarg)
  801cd1:	8b 43 08             	mov    0x8(%ebx),%eax
  801cd4:	85 c0                	test   %eax,%eax
  801cd6:	74 12                	je     801cea <argnextvalue+0x27>
		return 0;
	if (*args->curarg) {
  801cd8:	80 38 00             	cmpb   $0x0,(%eax)
  801cdb:	74 12                	je     801cef <argnextvalue+0x2c>
		args->argvalue = args->curarg;
  801cdd:	89 43 0c             	mov    %eax,0xc(%ebx)
		args->curarg = "";
  801ce0:	c7 43 08 21 35 80 00 	movl   $0x803521,0x8(%ebx)
		(*args->argc)--;
	} else {
		args->argvalue = 0;
		args->curarg = 0;
	}
	return (char*) args->argvalue;
  801ce7:	8b 43 0c             	mov    0xc(%ebx),%eax
}
  801cea:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  801ced:	c9                   	leave  
  801cee:	c3                   	ret    
	} else if (*args->argc > 1) {
  801cef:	8b 13                	mov    (%ebx),%edx
  801cf1:	83 3a 01             	cmpl   $0x1,(%edx)
  801cf4:	7f 10                	jg     801d06 <argnextvalue+0x43>
		args->argvalue = 0;
  801cf6:	c7 43 0c 00 00 00 00 	movl   $0x0,0xc(%ebx)
		args->curarg = 0;
  801cfd:	c7 43 08 00 00 00 00 	movl   $0x0,0x8(%ebx)
  801d04:	eb e1                	jmp    801ce7 <argnextvalue+0x24>
		args->argvalue = args->argv[1];
  801d06:	8b 43 04             	mov    0x4(%ebx),%eax
  801d09:	8b 48 04             	mov    0x4(%eax),%ecx
  801d0c:	89 4b 0c             	mov    %ecx,0xc(%ebx)
		memmove(args->argv + 1, args->argv + 2, sizeof(const char *) * (*args->argc - 1));
  801d0f:	83 ec 04             	sub    $0x4,%esp
  801d12:	8b 12                	mov    (%edx),%edx
  801d14:	8d 14 95 fc ff ff ff 	lea    -0x4(,%edx,4),%edx
  801d1b:	52                   	push   %edx
  801d1c:	8d 50 08             	lea    0x8(%eax),%edx
  801d1f:	52                   	push   %edx
  801d20:	83 c0 04             	add    $0x4,%eax
  801d23:	50                   	push   %eax
  801d24:	e8 f1 f6 ff ff       	call   80141a <memmove>
		(*args->argc)--;
  801d29:	8b 03                	mov    (%ebx),%eax
  801d2b:	83 28 01             	subl   $0x1,(%eax)
  801d2e:	83 c4 10             	add    $0x10,%esp
  801d31:	eb b4                	jmp    801ce7 <argnextvalue+0x24>

00801d33 <argvalue>:
{
  801d33:	f3 0f 1e fb          	endbr32 
  801d37:	55                   	push   %ebp
  801d38:	89 e5                	mov    %esp,%ebp
  801d3a:	83 ec 08             	sub    $0x8,%esp
  801d3d:	8b 55 08             	mov    0x8(%ebp),%edx
	return (char*) (args->argvalue ? args->argvalue : argnextvalue(args));
  801d40:	8b 42 0c             	mov    0xc(%edx),%eax
  801d43:	85 c0                	test   %eax,%eax
  801d45:	74 02                	je     801d49 <argvalue+0x16>
}
  801d47:	c9                   	leave  
  801d48:	c3                   	ret    
	return (char*) (args->argvalue ? args->argvalue : argnextvalue(args));
  801d49:	83 ec 0c             	sub    $0xc,%esp
  801d4c:	52                   	push   %edx
  801d4d:	e8 71 ff ff ff       	call   801cc3 <argnextvalue>
  801d52:	83 c4 10             	add    $0x10,%esp
  801d55:	eb f0                	jmp    801d47 <argvalue+0x14>

00801d57 <fd2num>:
// File descriptor manipulators
// --------------------------------------------------------------

int
fd2num(struct Fd *fd)
{
  801d57:	f3 0f 1e fb          	endbr32 
  801d5b:	55                   	push   %ebp
  801d5c:	89 e5                	mov    %esp,%ebp
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
  801d5e:	8b 45 08             	mov    0x8(%ebp),%eax
  801d61:	05 00 00 00 30       	add    $0x30000000,%eax
  801d66:	c1 e8 0c             	shr    $0xc,%eax
}
  801d69:	5d                   	pop    %ebp
  801d6a:	c3                   	ret    

00801d6b <fd2data>:

char*
fd2data(struct Fd *fd)
{
  801d6b:	f3 0f 1e fb          	endbr32 
  801d6f:	55                   	push   %ebp
  801d70:	89 e5                	mov    %esp,%ebp
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
  801d72:	8b 45 08             	mov    0x8(%ebp),%eax
  801d75:	05 00 00 00 30       	add    $0x30000000,%eax
	return INDEX2DATA(fd2num(fd));
  801d7a:	25 00 f0 ff ff       	and    $0xfffff000,%eax
  801d7f:	2d 00 00 fe 2f       	sub    $0x2ffe0000,%eax
}
  801d84:	5d                   	pop    %ebp
  801d85:	c3                   	ret    

00801d86 <fd_alloc>:
// Returns 0 on success, < 0 on error.  Errors are:
//	-E_MAX_FD: no more file descriptors
// On error, *fd_store is set to 0.
int
fd_alloc(struct Fd **fd_store)
{
  801d86:	f3 0f 1e fb          	endbr32 
  801d8a:	55                   	push   %ebp
  801d8b:	89 e5                	mov    %esp,%ebp
  801d8d:	b8 00 00 00 d0       	mov    $0xd0000000,%eax
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
		fd = INDEX2FD(i);
		if ((uvpd[PDX(fd)] & PTE_P) == 0 || (uvpt[PGNUM(fd)] & PTE_P) == 0) {
  801d92:	89 c2                	mov    %eax,%edx
  801d94:	c1 ea 16             	shr    $0x16,%edx
  801d97:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  801d9e:	f6 c2 01             	test   $0x1,%dl
  801da1:	74 2d                	je     801dd0 <fd_alloc+0x4a>
  801da3:	89 c2                	mov    %eax,%edx
  801da5:	c1 ea 0c             	shr    $0xc,%edx
  801da8:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  801daf:	f6 c2 01             	test   $0x1,%dl
  801db2:	74 1c                	je     801dd0 <fd_alloc+0x4a>
  801db4:	05 00 10 00 00       	add    $0x1000,%eax
	for (i = 0; i < MAXFD; i++) {
  801db9:	3d 00 00 02 d0       	cmp    $0xd0020000,%eax
  801dbe:	75 d2                	jne    801d92 <fd_alloc+0xc>
			*fd_store = fd;
			return 0;
		}
	}
	*fd_store = 0;
  801dc0:	8b 45 08             	mov    0x8(%ebp),%eax
  801dc3:	c7 00 00 00 00 00    	movl   $0x0,(%eax)
	return -E_MAX_OPEN;
  801dc9:	b8 f6 ff ff ff       	mov    $0xfffffff6,%eax
  801dce:	eb 0a                	jmp    801dda <fd_alloc+0x54>
			*fd_store = fd;
  801dd0:	8b 4d 08             	mov    0x8(%ebp),%ecx
  801dd3:	89 01                	mov    %eax,(%ecx)
			return 0;
  801dd5:	b8 00 00 00 00       	mov    $0x0,%eax
}
  801dda:	5d                   	pop    %ebp
  801ddb:	c3                   	ret    

00801ddc <fd_lookup>:
// Returns 0 on success (the page is in range and mapped), < 0 on error.
// Errors are:
//	-E_INVAL: fdnum was either not in range or not mapped.
int
fd_lookup(int fdnum, struct Fd **fd_store)
{
  801ddc:	f3 0f 1e fb          	endbr32 
  801de0:	55                   	push   %ebp
  801de1:	89 e5                	mov    %esp,%ebp
  801de3:	8b 45 08             	mov    0x8(%ebp),%eax
	struct Fd *fd;

	if (fdnum < 0 || fdnum >= MAXFD) {
  801de6:	83 f8 1f             	cmp    $0x1f,%eax
  801de9:	77 30                	ja     801e1b <fd_lookup+0x3f>
		if (debug)
			cprintf("[%08x] bad fd %d\n", thisenv->env_id, fdnum);
		return -E_INVAL;
	}
	fd = INDEX2FD(fdnum);
  801deb:	c1 e0 0c             	shl    $0xc,%eax
  801dee:	2d 00 00 00 30       	sub    $0x30000000,%eax
	if (!(uvpd[PDX(fd)] & PTE_P) || !(uvpt[PGNUM(fd)] & PTE_P)) {
  801df3:	8b 15 00 dd 7b ef    	mov    0xef7bdd00,%edx
  801df9:	f6 c2 01             	test   $0x1,%dl
  801dfc:	74 24                	je     801e22 <fd_lookup+0x46>
  801dfe:	89 c2                	mov    %eax,%edx
  801e00:	c1 ea 0c             	shr    $0xc,%edx
  801e03:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  801e0a:	f6 c2 01             	test   $0x1,%dl
  801e0d:	74 1a                	je     801e29 <fd_lookup+0x4d>
		if (debug)
			cprintf("[%08x] closed fd %d\n", thisenv->env_id, fdnum);
		return -E_INVAL;
	}
	*fd_store = fd;
  801e0f:	8b 55 0c             	mov    0xc(%ebp),%edx
  801e12:	89 02                	mov    %eax,(%edx)
	return 0;
  801e14:	b8 00 00 00 00       	mov    $0x0,%eax
}
  801e19:	5d                   	pop    %ebp
  801e1a:	c3                   	ret    
		return -E_INVAL;
  801e1b:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  801e20:	eb f7                	jmp    801e19 <fd_lookup+0x3d>
		return -E_INVAL;
  801e22:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  801e27:	eb f0                	jmp    801e19 <fd_lookup+0x3d>
  801e29:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  801e2e:	eb e9                	jmp    801e19 <fd_lookup+0x3d>

00801e30 <dev_lookup>:
	0
};

int
dev_lookup(int dev_id, struct Dev **dev)
{
  801e30:	f3 0f 1e fb          	endbr32 
  801e34:	55                   	push   %ebp
  801e35:	89 e5                	mov    %esp,%ebp
  801e37:	83 ec 08             	sub    $0x8,%esp
  801e3a:	8b 4d 08             	mov    0x8(%ebp),%ecx
  801e3d:	ba 48 3c 80 00       	mov    $0x803c48,%edx
	int i;
	for (i = 0; devtab[i]; i++)
  801e42:	b8 20 40 80 00       	mov    $0x804020,%eax
		if (devtab[i]->dev_id == dev_id) {
  801e47:	39 08                	cmp    %ecx,(%eax)
  801e49:	74 33                	je     801e7e <dev_lookup+0x4e>
  801e4b:	83 c2 04             	add    $0x4,%edx
	for (i = 0; devtab[i]; i++)
  801e4e:	8b 02                	mov    (%edx),%eax
  801e50:	85 c0                	test   %eax,%eax
  801e52:	75 f3                	jne    801e47 <dev_lookup+0x17>
			*dev = devtab[i];
			return 0;
		}
	cprintf("[%08x] unknown device type %d\n", thisenv->env_id, dev_id);
  801e54:	a1 24 54 80 00       	mov    0x805424,%eax
  801e59:	8b 40 48             	mov    0x48(%eax),%eax
  801e5c:	83 ec 04             	sub    $0x4,%esp
  801e5f:	51                   	push   %ecx
  801e60:	50                   	push   %eax
  801e61:	68 cc 3b 80 00       	push   $0x803bcc
  801e66:	e8 2c ed ff ff       	call   800b97 <cprintf>
	*dev = 0;
  801e6b:	8b 45 0c             	mov    0xc(%ebp),%eax
  801e6e:	c7 00 00 00 00 00    	movl   $0x0,(%eax)
	return -E_INVAL;
  801e74:	83 c4 10             	add    $0x10,%esp
  801e77:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  801e7c:	c9                   	leave  
  801e7d:	c3                   	ret    
			*dev = devtab[i];
  801e7e:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801e81:	89 01                	mov    %eax,(%ecx)
			return 0;
  801e83:	b8 00 00 00 00       	mov    $0x0,%eax
  801e88:	eb f2                	jmp    801e7c <dev_lookup+0x4c>

00801e8a <fd_close>:
{
  801e8a:	f3 0f 1e fb          	endbr32 
  801e8e:	55                   	push   %ebp
  801e8f:	89 e5                	mov    %esp,%ebp
  801e91:	57                   	push   %edi
  801e92:	56                   	push   %esi
  801e93:	53                   	push   %ebx
  801e94:	83 ec 24             	sub    $0x24,%esp
  801e97:	8b 75 08             	mov    0x8(%ebp),%esi
  801e9a:	8b 7d 0c             	mov    0xc(%ebp),%edi
	if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
  801e9d:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  801ea0:	50                   	push   %eax
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
  801ea1:	8d 86 00 00 00 30    	lea    0x30000000(%esi),%eax
  801ea7:	c1 e8 0c             	shr    $0xc,%eax
	if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
  801eaa:	50                   	push   %eax
  801eab:	e8 2c ff ff ff       	call   801ddc <fd_lookup>
  801eb0:	89 c3                	mov    %eax,%ebx
  801eb2:	83 c4 10             	add    $0x10,%esp
  801eb5:	85 c0                	test   %eax,%eax
  801eb7:	78 05                	js     801ebe <fd_close+0x34>
	    || fd != fd2)
  801eb9:	39 75 e4             	cmp    %esi,-0x1c(%ebp)
  801ebc:	74 16                	je     801ed4 <fd_close+0x4a>
		return (must_exist ? r : 0);
  801ebe:	89 f8                	mov    %edi,%eax
  801ec0:	84 c0                	test   %al,%al
  801ec2:	b8 00 00 00 00       	mov    $0x0,%eax
  801ec7:	0f 44 d8             	cmove  %eax,%ebx
}
  801eca:	89 d8                	mov    %ebx,%eax
  801ecc:	8d 65 f4             	lea    -0xc(%ebp),%esp
  801ecf:	5b                   	pop    %ebx
  801ed0:	5e                   	pop    %esi
  801ed1:	5f                   	pop    %edi
  801ed2:	5d                   	pop    %ebp
  801ed3:	c3                   	ret    
	if ((r = dev_lookup(fd->fd_dev_id, &dev)) >= 0) {
  801ed4:	83 ec 08             	sub    $0x8,%esp
  801ed7:	8d 45 e0             	lea    -0x20(%ebp),%eax
  801eda:	50                   	push   %eax
  801edb:	ff 36                	pushl  (%esi)
  801edd:	e8 4e ff ff ff       	call   801e30 <dev_lookup>
  801ee2:	89 c3                	mov    %eax,%ebx
  801ee4:	83 c4 10             	add    $0x10,%esp
  801ee7:	85 c0                	test   %eax,%eax
  801ee9:	78 1a                	js     801f05 <fd_close+0x7b>
		if (dev->dev_close)
  801eeb:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801eee:	8b 40 10             	mov    0x10(%eax),%eax
			r = 0;
  801ef1:	bb 00 00 00 00       	mov    $0x0,%ebx
		if (dev->dev_close)
  801ef6:	85 c0                	test   %eax,%eax
  801ef8:	74 0b                	je     801f05 <fd_close+0x7b>
			r = (*dev->dev_close)(fd);
  801efa:	83 ec 0c             	sub    $0xc,%esp
  801efd:	56                   	push   %esi
  801efe:	ff d0                	call   *%eax
  801f00:	89 c3                	mov    %eax,%ebx
  801f02:	83 c4 10             	add    $0x10,%esp
	(void) sys_page_unmap(0, fd);
  801f05:	83 ec 08             	sub    $0x8,%esp
  801f08:	56                   	push   %esi
  801f09:	6a 00                	push   $0x0
  801f0b:	e8 23 f8 ff ff       	call   801733 <sys_page_unmap>
	return r;
  801f10:	83 c4 10             	add    $0x10,%esp
  801f13:	eb b5                	jmp    801eca <fd_close+0x40>

00801f15 <close>:

int
close(int fdnum)
{
  801f15:	f3 0f 1e fb          	endbr32 
  801f19:	55                   	push   %ebp
  801f1a:	89 e5                	mov    %esp,%ebp
  801f1c:	83 ec 20             	sub    $0x20,%esp
	struct Fd *fd;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  801f1f:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801f22:	50                   	push   %eax
  801f23:	ff 75 08             	pushl  0x8(%ebp)
  801f26:	e8 b1 fe ff ff       	call   801ddc <fd_lookup>
  801f2b:	83 c4 10             	add    $0x10,%esp
  801f2e:	85 c0                	test   %eax,%eax
  801f30:	79 02                	jns    801f34 <close+0x1f>
		return r;
	else
		return fd_close(fd, 1);
}
  801f32:	c9                   	leave  
  801f33:	c3                   	ret    
		return fd_close(fd, 1);
  801f34:	83 ec 08             	sub    $0x8,%esp
  801f37:	6a 01                	push   $0x1
  801f39:	ff 75 f4             	pushl  -0xc(%ebp)
  801f3c:	e8 49 ff ff ff       	call   801e8a <fd_close>
  801f41:	83 c4 10             	add    $0x10,%esp
  801f44:	eb ec                	jmp    801f32 <close+0x1d>

00801f46 <close_all>:

void
close_all(void)
{
  801f46:	f3 0f 1e fb          	endbr32 
  801f4a:	55                   	push   %ebp
  801f4b:	89 e5                	mov    %esp,%ebp
  801f4d:	53                   	push   %ebx
  801f4e:	83 ec 04             	sub    $0x4,%esp
	int i;
	for (i = 0; i < MAXFD; i++)
  801f51:	bb 00 00 00 00       	mov    $0x0,%ebx
		close(i);
  801f56:	83 ec 0c             	sub    $0xc,%esp
  801f59:	53                   	push   %ebx
  801f5a:	e8 b6 ff ff ff       	call   801f15 <close>
	for (i = 0; i < MAXFD; i++)
  801f5f:	83 c3 01             	add    $0x1,%ebx
  801f62:	83 c4 10             	add    $0x10,%esp
  801f65:	83 fb 20             	cmp    $0x20,%ebx
  801f68:	75 ec                	jne    801f56 <close_all+0x10>
}
  801f6a:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  801f6d:	c9                   	leave  
  801f6e:	c3                   	ret    

00801f6f <dup>:
// file and the file offset of the other.
// Closes any previously open file descriptor at 'newfdnum'.
// This is implemented using virtual memory tricks (of course!).
int
dup(int oldfdnum, int newfdnum)
{
  801f6f:	f3 0f 1e fb          	endbr32 
  801f73:	55                   	push   %ebp
  801f74:	89 e5                	mov    %esp,%ebp
  801f76:	57                   	push   %edi
  801f77:	56                   	push   %esi
  801f78:	53                   	push   %ebx
  801f79:	83 ec 24             	sub    $0x24,%esp
	int r;
	char *ova, *nva;
	pte_t pte;
	struct Fd *oldfd, *newfd;

	if ((r = fd_lookup(oldfdnum, &oldfd)) < 0)
  801f7c:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  801f7f:	50                   	push   %eax
  801f80:	ff 75 08             	pushl  0x8(%ebp)
  801f83:	e8 54 fe ff ff       	call   801ddc <fd_lookup>
  801f88:	89 c3                	mov    %eax,%ebx
  801f8a:	83 c4 10             	add    $0x10,%esp
  801f8d:	85 c0                	test   %eax,%eax
  801f8f:	0f 88 81 00 00 00    	js     802016 <dup+0xa7>
		return r;
	close(newfdnum);
  801f95:	83 ec 0c             	sub    $0xc,%esp
  801f98:	ff 75 0c             	pushl  0xc(%ebp)
  801f9b:	e8 75 ff ff ff       	call   801f15 <close>

	newfd = INDEX2FD(newfdnum);
  801fa0:	8b 75 0c             	mov    0xc(%ebp),%esi
  801fa3:	c1 e6 0c             	shl    $0xc,%esi
  801fa6:	81 ee 00 00 00 30    	sub    $0x30000000,%esi
	ova = fd2data(oldfd);
  801fac:	83 c4 04             	add    $0x4,%esp
  801faf:	ff 75 e4             	pushl  -0x1c(%ebp)
  801fb2:	e8 b4 fd ff ff       	call   801d6b <fd2data>
  801fb7:	89 c3                	mov    %eax,%ebx
	nva = fd2data(newfd);
  801fb9:	89 34 24             	mov    %esi,(%esp)
  801fbc:	e8 aa fd ff ff       	call   801d6b <fd2data>
  801fc1:	83 c4 10             	add    $0x10,%esp
  801fc4:	89 c7                	mov    %eax,%edi

	if ((uvpd[PDX(ova)] & PTE_P) && (uvpt[PGNUM(ova)] & PTE_P))
  801fc6:	89 d8                	mov    %ebx,%eax
  801fc8:	c1 e8 16             	shr    $0x16,%eax
  801fcb:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  801fd2:	a8 01                	test   $0x1,%al
  801fd4:	74 11                	je     801fe7 <dup+0x78>
  801fd6:	89 d8                	mov    %ebx,%eax
  801fd8:	c1 e8 0c             	shr    $0xc,%eax
  801fdb:	8b 14 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%edx
  801fe2:	f6 c2 01             	test   $0x1,%dl
  801fe5:	75 39                	jne    802020 <dup+0xb1>
		if ((r = sys_page_map(0, ova, 0, nva, uvpt[PGNUM(ova)] & PTE_SYSCALL)) < 0)
			goto err;
	if ((r = sys_page_map(0, oldfd, 0, newfd, uvpt[PGNUM(oldfd)] & PTE_SYSCALL)) < 0)
  801fe7:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  801fea:	89 d0                	mov    %edx,%eax
  801fec:	c1 e8 0c             	shr    $0xc,%eax
  801fef:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
  801ff6:	83 ec 0c             	sub    $0xc,%esp
  801ff9:	25 07 0e 00 00       	and    $0xe07,%eax
  801ffe:	50                   	push   %eax
  801fff:	56                   	push   %esi
  802000:	6a 00                	push   $0x0
  802002:	52                   	push   %edx
  802003:	6a 00                	push   $0x0
  802005:	e8 e3 f6 ff ff       	call   8016ed <sys_page_map>
  80200a:	89 c3                	mov    %eax,%ebx
  80200c:	83 c4 20             	add    $0x20,%esp
  80200f:	85 c0                	test   %eax,%eax
  802011:	78 31                	js     802044 <dup+0xd5>
		goto err;

	return newfdnum;
  802013:	8b 5d 0c             	mov    0xc(%ebp),%ebx

err:
	sys_page_unmap(0, newfd);
	sys_page_unmap(0, nva);
	return r;
}
  802016:	89 d8                	mov    %ebx,%eax
  802018:	8d 65 f4             	lea    -0xc(%ebp),%esp
  80201b:	5b                   	pop    %ebx
  80201c:	5e                   	pop    %esi
  80201d:	5f                   	pop    %edi
  80201e:	5d                   	pop    %ebp
  80201f:	c3                   	ret    
		if ((r = sys_page_map(0, ova, 0, nva, uvpt[PGNUM(ova)] & PTE_SYSCALL)) < 0)
  802020:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
  802027:	83 ec 0c             	sub    $0xc,%esp
  80202a:	25 07 0e 00 00       	and    $0xe07,%eax
  80202f:	50                   	push   %eax
  802030:	57                   	push   %edi
  802031:	6a 00                	push   $0x0
  802033:	53                   	push   %ebx
  802034:	6a 00                	push   $0x0
  802036:	e8 b2 f6 ff ff       	call   8016ed <sys_page_map>
  80203b:	89 c3                	mov    %eax,%ebx
  80203d:	83 c4 20             	add    $0x20,%esp
  802040:	85 c0                	test   %eax,%eax
  802042:	79 a3                	jns    801fe7 <dup+0x78>
	sys_page_unmap(0, newfd);
  802044:	83 ec 08             	sub    $0x8,%esp
  802047:	56                   	push   %esi
  802048:	6a 00                	push   $0x0
  80204a:	e8 e4 f6 ff ff       	call   801733 <sys_page_unmap>
	sys_page_unmap(0, nva);
  80204f:	83 c4 08             	add    $0x8,%esp
  802052:	57                   	push   %edi
  802053:	6a 00                	push   $0x0
  802055:	e8 d9 f6 ff ff       	call   801733 <sys_page_unmap>
	return r;
  80205a:	83 c4 10             	add    $0x10,%esp
  80205d:	eb b7                	jmp    802016 <dup+0xa7>

0080205f <read>:

ssize_t
read(int fdnum, void *buf, size_t n)
{
  80205f:	f3 0f 1e fb          	endbr32 
  802063:	55                   	push   %ebp
  802064:	89 e5                	mov    %esp,%ebp
  802066:	53                   	push   %ebx
  802067:	83 ec 1c             	sub    $0x1c,%esp
  80206a:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  80206d:	8d 45 f0             	lea    -0x10(%ebp),%eax
  802070:	50                   	push   %eax
  802071:	53                   	push   %ebx
  802072:	e8 65 fd ff ff       	call   801ddc <fd_lookup>
  802077:	83 c4 10             	add    $0x10,%esp
  80207a:	85 c0                	test   %eax,%eax
  80207c:	78 3f                	js     8020bd <read+0x5e>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  80207e:	83 ec 08             	sub    $0x8,%esp
  802081:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802084:	50                   	push   %eax
  802085:	8b 45 f0             	mov    -0x10(%ebp),%eax
  802088:	ff 30                	pushl  (%eax)
  80208a:	e8 a1 fd ff ff       	call   801e30 <dev_lookup>
  80208f:	83 c4 10             	add    $0x10,%esp
  802092:	85 c0                	test   %eax,%eax
  802094:	78 27                	js     8020bd <read+0x5e>
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_WRONLY) {
  802096:	8b 55 f0             	mov    -0x10(%ebp),%edx
  802099:	8b 42 08             	mov    0x8(%edx),%eax
  80209c:	83 e0 03             	and    $0x3,%eax
  80209f:	83 f8 01             	cmp    $0x1,%eax
  8020a2:	74 1e                	je     8020c2 <read+0x63>
		cprintf("[%08x] read %d -- bad mode\n", thisenv->env_id, fdnum);
		return -E_INVAL;
	}
	if (!dev->dev_read)
  8020a4:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8020a7:	8b 40 08             	mov    0x8(%eax),%eax
  8020aa:	85 c0                	test   %eax,%eax
  8020ac:	74 35                	je     8020e3 <read+0x84>
		return -E_NOT_SUPP;
	return (*dev->dev_read)(fd, buf, n);
  8020ae:	83 ec 04             	sub    $0x4,%esp
  8020b1:	ff 75 10             	pushl  0x10(%ebp)
  8020b4:	ff 75 0c             	pushl  0xc(%ebp)
  8020b7:	52                   	push   %edx
  8020b8:	ff d0                	call   *%eax
  8020ba:	83 c4 10             	add    $0x10,%esp
}
  8020bd:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  8020c0:	c9                   	leave  
  8020c1:	c3                   	ret    
		cprintf("[%08x] read %d -- bad mode\n", thisenv->env_id, fdnum);
  8020c2:	a1 24 54 80 00       	mov    0x805424,%eax
  8020c7:	8b 40 48             	mov    0x48(%eax),%eax
  8020ca:	83 ec 04             	sub    $0x4,%esp
  8020cd:	53                   	push   %ebx
  8020ce:	50                   	push   %eax
  8020cf:	68 0d 3c 80 00       	push   $0x803c0d
  8020d4:	e8 be ea ff ff       	call   800b97 <cprintf>
		return -E_INVAL;
  8020d9:	83 c4 10             	add    $0x10,%esp
  8020dc:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  8020e1:	eb da                	jmp    8020bd <read+0x5e>
		return -E_NOT_SUPP;
  8020e3:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8020e8:	eb d3                	jmp    8020bd <read+0x5e>

008020ea <readn>:

ssize_t
readn(int fdnum, void *buf, size_t n)
{
  8020ea:	f3 0f 1e fb          	endbr32 
  8020ee:	55                   	push   %ebp
  8020ef:	89 e5                	mov    %esp,%ebp
  8020f1:	57                   	push   %edi
  8020f2:	56                   	push   %esi
  8020f3:	53                   	push   %ebx
  8020f4:	83 ec 0c             	sub    $0xc,%esp
  8020f7:	8b 7d 08             	mov    0x8(%ebp),%edi
  8020fa:	8b 75 10             	mov    0x10(%ebp),%esi
	int m, tot;

	for (tot = 0; tot < n; tot += m) {
  8020fd:	bb 00 00 00 00       	mov    $0x0,%ebx
  802102:	eb 02                	jmp    802106 <readn+0x1c>
  802104:	01 c3                	add    %eax,%ebx
  802106:	39 f3                	cmp    %esi,%ebx
  802108:	73 21                	jae    80212b <readn+0x41>
		m = read(fdnum, (char*)buf + tot, n - tot);
  80210a:	83 ec 04             	sub    $0x4,%esp
  80210d:	89 f0                	mov    %esi,%eax
  80210f:	29 d8                	sub    %ebx,%eax
  802111:	50                   	push   %eax
  802112:	89 d8                	mov    %ebx,%eax
  802114:	03 45 0c             	add    0xc(%ebp),%eax
  802117:	50                   	push   %eax
  802118:	57                   	push   %edi
  802119:	e8 41 ff ff ff       	call   80205f <read>
		if (m < 0)
  80211e:	83 c4 10             	add    $0x10,%esp
  802121:	85 c0                	test   %eax,%eax
  802123:	78 04                	js     802129 <readn+0x3f>
			return m;
		if (m == 0)
  802125:	75 dd                	jne    802104 <readn+0x1a>
  802127:	eb 02                	jmp    80212b <readn+0x41>
		m = read(fdnum, (char*)buf + tot, n - tot);
  802129:	89 c3                	mov    %eax,%ebx
			break;
	}
	return tot;
}
  80212b:	89 d8                	mov    %ebx,%eax
  80212d:	8d 65 f4             	lea    -0xc(%ebp),%esp
  802130:	5b                   	pop    %ebx
  802131:	5e                   	pop    %esi
  802132:	5f                   	pop    %edi
  802133:	5d                   	pop    %ebp
  802134:	c3                   	ret    

00802135 <write>:

ssize_t
write(int fdnum, const void *buf, size_t n)
{
  802135:	f3 0f 1e fb          	endbr32 
  802139:	55                   	push   %ebp
  80213a:	89 e5                	mov    %esp,%ebp
  80213c:	53                   	push   %ebx
  80213d:	83 ec 1c             	sub    $0x1c,%esp
  802140:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  802143:	8d 45 f0             	lea    -0x10(%ebp),%eax
  802146:	50                   	push   %eax
  802147:	53                   	push   %ebx
  802148:	e8 8f fc ff ff       	call   801ddc <fd_lookup>
  80214d:	83 c4 10             	add    $0x10,%esp
  802150:	85 c0                	test   %eax,%eax
  802152:	78 3a                	js     80218e <write+0x59>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  802154:	83 ec 08             	sub    $0x8,%esp
  802157:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80215a:	50                   	push   %eax
  80215b:	8b 45 f0             	mov    -0x10(%ebp),%eax
  80215e:	ff 30                	pushl  (%eax)
  802160:	e8 cb fc ff ff       	call   801e30 <dev_lookup>
  802165:	83 c4 10             	add    $0x10,%esp
  802168:	85 c0                	test   %eax,%eax
  80216a:	78 22                	js     80218e <write+0x59>
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  80216c:	8b 45 f0             	mov    -0x10(%ebp),%eax
  80216f:	f6 40 08 03          	testb  $0x3,0x8(%eax)
  802173:	74 1e                	je     802193 <write+0x5e>
		return -E_INVAL;
	}
	if (debug)
		cprintf("write %d %p %d via dev %s\n",
			fdnum, buf, n, dev->dev_name);
	if (!dev->dev_write)
  802175:	8b 55 f4             	mov    -0xc(%ebp),%edx
  802178:	8b 52 0c             	mov    0xc(%edx),%edx
  80217b:	85 d2                	test   %edx,%edx
  80217d:	74 35                	je     8021b4 <write+0x7f>
		return -E_NOT_SUPP;
	return (*dev->dev_write)(fd, buf, n);
  80217f:	83 ec 04             	sub    $0x4,%esp
  802182:	ff 75 10             	pushl  0x10(%ebp)
  802185:	ff 75 0c             	pushl  0xc(%ebp)
  802188:	50                   	push   %eax
  802189:	ff d2                	call   *%edx
  80218b:	83 c4 10             	add    $0x10,%esp
}
  80218e:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  802191:	c9                   	leave  
  802192:	c3                   	ret    
		cprintf("[%08x] write %d -- bad mode\n", thisenv->env_id, fdnum);
  802193:	a1 24 54 80 00       	mov    0x805424,%eax
  802198:	8b 40 48             	mov    0x48(%eax),%eax
  80219b:	83 ec 04             	sub    $0x4,%esp
  80219e:	53                   	push   %ebx
  80219f:	50                   	push   %eax
  8021a0:	68 29 3c 80 00       	push   $0x803c29
  8021a5:	e8 ed e9 ff ff       	call   800b97 <cprintf>
		return -E_INVAL;
  8021aa:	83 c4 10             	add    $0x10,%esp
  8021ad:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  8021b2:	eb da                	jmp    80218e <write+0x59>
		return -E_NOT_SUPP;
  8021b4:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8021b9:	eb d3                	jmp    80218e <write+0x59>

008021bb <seek>:

int
seek(int fdnum, off_t offset)
{
  8021bb:	f3 0f 1e fb          	endbr32 
  8021bf:	55                   	push   %ebp
  8021c0:	89 e5                	mov    %esp,%ebp
  8021c2:	83 ec 20             	sub    $0x20,%esp
	int r;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  8021c5:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8021c8:	50                   	push   %eax
  8021c9:	ff 75 08             	pushl  0x8(%ebp)
  8021cc:	e8 0b fc ff ff       	call   801ddc <fd_lookup>
  8021d1:	83 c4 10             	add    $0x10,%esp
  8021d4:	85 c0                	test   %eax,%eax
  8021d6:	78 0e                	js     8021e6 <seek+0x2b>
		return r;
	fd->fd_offset = offset;
  8021d8:	8b 55 0c             	mov    0xc(%ebp),%edx
  8021db:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8021de:	89 50 04             	mov    %edx,0x4(%eax)
	return 0;
  8021e1:	b8 00 00 00 00       	mov    $0x0,%eax
}
  8021e6:	c9                   	leave  
  8021e7:	c3                   	ret    

008021e8 <ftruncate>:

int
ftruncate(int fdnum, off_t newsize)
{
  8021e8:	f3 0f 1e fb          	endbr32 
  8021ec:	55                   	push   %ebp
  8021ed:	89 e5                	mov    %esp,%ebp
  8021ef:	53                   	push   %ebx
  8021f0:	83 ec 1c             	sub    $0x1c,%esp
  8021f3:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  8021f6:	8d 45 f0             	lea    -0x10(%ebp),%eax
  8021f9:	50                   	push   %eax
  8021fa:	53                   	push   %ebx
  8021fb:	e8 dc fb ff ff       	call   801ddc <fd_lookup>
  802200:	83 c4 10             	add    $0x10,%esp
  802203:	85 c0                	test   %eax,%eax
  802205:	78 37                	js     80223e <ftruncate+0x56>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  802207:	83 ec 08             	sub    $0x8,%esp
  80220a:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80220d:	50                   	push   %eax
  80220e:	8b 45 f0             	mov    -0x10(%ebp),%eax
  802211:	ff 30                	pushl  (%eax)
  802213:	e8 18 fc ff ff       	call   801e30 <dev_lookup>
  802218:	83 c4 10             	add    $0x10,%esp
  80221b:	85 c0                	test   %eax,%eax
  80221d:	78 1f                	js     80223e <ftruncate+0x56>
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  80221f:	8b 45 f0             	mov    -0x10(%ebp),%eax
  802222:	f6 40 08 03          	testb  $0x3,0x8(%eax)
  802226:	74 1b                	je     802243 <ftruncate+0x5b>
		cprintf("[%08x] ftruncate %d -- bad mode\n",
			thisenv->env_id, fdnum);
		return -E_INVAL;
	}
	if (!dev->dev_trunc)
  802228:	8b 55 f4             	mov    -0xc(%ebp),%edx
  80222b:	8b 52 18             	mov    0x18(%edx),%edx
  80222e:	85 d2                	test   %edx,%edx
  802230:	74 32                	je     802264 <ftruncate+0x7c>
		return -E_NOT_SUPP;
	return (*dev->dev_trunc)(fd, newsize);
  802232:	83 ec 08             	sub    $0x8,%esp
  802235:	ff 75 0c             	pushl  0xc(%ebp)
  802238:	50                   	push   %eax
  802239:	ff d2                	call   *%edx
  80223b:	83 c4 10             	add    $0x10,%esp
}
  80223e:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  802241:	c9                   	leave  
  802242:	c3                   	ret    
			thisenv->env_id, fdnum);
  802243:	a1 24 54 80 00       	mov    0x805424,%eax
		cprintf("[%08x] ftruncate %d -- bad mode\n",
  802248:	8b 40 48             	mov    0x48(%eax),%eax
  80224b:	83 ec 04             	sub    $0x4,%esp
  80224e:	53                   	push   %ebx
  80224f:	50                   	push   %eax
  802250:	68 ec 3b 80 00       	push   $0x803bec
  802255:	e8 3d e9 ff ff       	call   800b97 <cprintf>
		return -E_INVAL;
  80225a:	83 c4 10             	add    $0x10,%esp
  80225d:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  802262:	eb da                	jmp    80223e <ftruncate+0x56>
		return -E_NOT_SUPP;
  802264:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  802269:	eb d3                	jmp    80223e <ftruncate+0x56>

0080226b <fstat>:

int
fstat(int fdnum, struct Stat *stat)
{
  80226b:	f3 0f 1e fb          	endbr32 
  80226f:	55                   	push   %ebp
  802270:	89 e5                	mov    %esp,%ebp
  802272:	53                   	push   %ebx
  802273:	83 ec 1c             	sub    $0x1c,%esp
  802276:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  802279:	8d 45 f0             	lea    -0x10(%ebp),%eax
  80227c:	50                   	push   %eax
  80227d:	ff 75 08             	pushl  0x8(%ebp)
  802280:	e8 57 fb ff ff       	call   801ddc <fd_lookup>
  802285:	83 c4 10             	add    $0x10,%esp
  802288:	85 c0                	test   %eax,%eax
  80228a:	78 4b                	js     8022d7 <fstat+0x6c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  80228c:	83 ec 08             	sub    $0x8,%esp
  80228f:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802292:	50                   	push   %eax
  802293:	8b 45 f0             	mov    -0x10(%ebp),%eax
  802296:	ff 30                	pushl  (%eax)
  802298:	e8 93 fb ff ff       	call   801e30 <dev_lookup>
  80229d:	83 c4 10             	add    $0x10,%esp
  8022a0:	85 c0                	test   %eax,%eax
  8022a2:	78 33                	js     8022d7 <fstat+0x6c>
		return r;
	if (!dev->dev_stat)
  8022a4:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8022a7:	83 78 14 00          	cmpl   $0x0,0x14(%eax)
  8022ab:	74 2f                	je     8022dc <fstat+0x71>
		return -E_NOT_SUPP;
	stat->st_name[0] = 0;
  8022ad:	c6 03 00             	movb   $0x0,(%ebx)
	stat->st_size = 0;
  8022b0:	c7 83 80 00 00 00 00 	movl   $0x0,0x80(%ebx)
  8022b7:	00 00 00 
	stat->st_isdir = 0;
  8022ba:	c7 83 84 00 00 00 00 	movl   $0x0,0x84(%ebx)
  8022c1:	00 00 00 
	stat->st_dev = dev;
  8022c4:	89 83 88 00 00 00    	mov    %eax,0x88(%ebx)
	return (*dev->dev_stat)(fd, stat);
  8022ca:	83 ec 08             	sub    $0x8,%esp
  8022cd:	53                   	push   %ebx
  8022ce:	ff 75 f0             	pushl  -0x10(%ebp)
  8022d1:	ff 50 14             	call   *0x14(%eax)
  8022d4:	83 c4 10             	add    $0x10,%esp
}
  8022d7:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  8022da:	c9                   	leave  
  8022db:	c3                   	ret    
		return -E_NOT_SUPP;
  8022dc:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8022e1:	eb f4                	jmp    8022d7 <fstat+0x6c>

008022e3 <stat>:

int
stat(const char *path, struct Stat *stat)
{
  8022e3:	f3 0f 1e fb          	endbr32 
  8022e7:	55                   	push   %ebp
  8022e8:	89 e5                	mov    %esp,%ebp
  8022ea:	56                   	push   %esi
  8022eb:	53                   	push   %ebx
	int fd, r;

	if ((fd = open(path, O_RDONLY)) < 0)
  8022ec:	83 ec 08             	sub    $0x8,%esp
  8022ef:	6a 00                	push   $0x0
  8022f1:	ff 75 08             	pushl  0x8(%ebp)
  8022f4:	e8 fb 01 00 00       	call   8024f4 <open>
  8022f9:	89 c3                	mov    %eax,%ebx
  8022fb:	83 c4 10             	add    $0x10,%esp
  8022fe:	85 c0                	test   %eax,%eax
  802300:	78 1b                	js     80231d <stat+0x3a>
		return fd;
	r = fstat(fd, stat);
  802302:	83 ec 08             	sub    $0x8,%esp
  802305:	ff 75 0c             	pushl  0xc(%ebp)
  802308:	50                   	push   %eax
  802309:	e8 5d ff ff ff       	call   80226b <fstat>
  80230e:	89 c6                	mov    %eax,%esi
	close(fd);
  802310:	89 1c 24             	mov    %ebx,(%esp)
  802313:	e8 fd fb ff ff       	call   801f15 <close>
	return r;
  802318:	83 c4 10             	add    $0x10,%esp
  80231b:	89 f3                	mov    %esi,%ebx
}
  80231d:	89 d8                	mov    %ebx,%eax
  80231f:	8d 65 f8             	lea    -0x8(%ebp),%esp
  802322:	5b                   	pop    %ebx
  802323:	5e                   	pop    %esi
  802324:	5d                   	pop    %ebp
  802325:	c3                   	ret    

00802326 <fsipc>:
// type: request code, passed as the simple integer IPC value.
// dstva: virtual address at which to receive reply page, 0 if none.
// Returns result from the file server.
static int
fsipc(unsigned type, void *dstva)
{
  802326:	55                   	push   %ebp
  802327:	89 e5                	mov    %esp,%ebp
  802329:	56                   	push   %esi
  80232a:	53                   	push   %ebx
  80232b:	89 c6                	mov    %eax,%esi
  80232d:	89 d3                	mov    %edx,%ebx
	static envid_t fsenv;
	if (fsenv == 0)
  80232f:	83 3d 20 54 80 00 00 	cmpl   $0x0,0x805420
  802336:	74 27                	je     80235f <fsipc+0x39>
	static_assert(sizeof(fsipcbuf) == PGSIZE);

	if (debug)
		cprintf("[%08x] fsipc %d %08x\n", thisenv->env_id, type, *(uint32_t *)&fsipcbuf);

	ipc_send(fsenv, type, &fsipcbuf, PTE_P | PTE_W | PTE_U);
  802338:	6a 07                	push   $0x7
  80233a:	68 00 60 80 00       	push   $0x806000
  80233f:	56                   	push   %esi
  802340:	ff 35 20 54 80 00    	pushl  0x805420
  802346:	e8 61 0e 00 00       	call   8031ac <ipc_send>
	return ipc_recv(NULL, dstva, NULL);
  80234b:	83 c4 0c             	add    $0xc,%esp
  80234e:	6a 00                	push   $0x0
  802350:	53                   	push   %ebx
  802351:	6a 00                	push   $0x0
  802353:	e8 d3 0d 00 00       	call   80312b <ipc_recv>
}
  802358:	8d 65 f8             	lea    -0x8(%ebp),%esp
  80235b:	5b                   	pop    %ebx
  80235c:	5e                   	pop    %esi
  80235d:	5d                   	pop    %ebp
  80235e:	c3                   	ret    
		fsenv = ipc_find_env(ENV_TYPE_FS);
  80235f:	83 ec 0c             	sub    $0xc,%esp
  802362:	6a 01                	push   $0x1
  802364:	e8 9b 0e 00 00       	call   803204 <ipc_find_env>
  802369:	a3 20 54 80 00       	mov    %eax,0x805420
  80236e:	83 c4 10             	add    $0x10,%esp
  802371:	eb c5                	jmp    802338 <fsipc+0x12>

00802373 <devfile_trunc>:
}

// Truncate or extend an open file to 'size' bytes
static int
devfile_trunc(struct Fd *fd, off_t newsize)
{
  802373:	f3 0f 1e fb          	endbr32 
  802377:	55                   	push   %ebp
  802378:	89 e5                	mov    %esp,%ebp
  80237a:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.set_size.req_fileid = fd->fd_file.id;
  80237d:	8b 45 08             	mov    0x8(%ebp),%eax
  802380:	8b 40 0c             	mov    0xc(%eax),%eax
  802383:	a3 00 60 80 00       	mov    %eax,0x806000
	fsipcbuf.set_size.req_size = newsize;
  802388:	8b 45 0c             	mov    0xc(%ebp),%eax
  80238b:	a3 04 60 80 00       	mov    %eax,0x806004
	return fsipc(FSREQ_SET_SIZE, NULL);
  802390:	ba 00 00 00 00       	mov    $0x0,%edx
  802395:	b8 02 00 00 00       	mov    $0x2,%eax
  80239a:	e8 87 ff ff ff       	call   802326 <fsipc>
}
  80239f:	c9                   	leave  
  8023a0:	c3                   	ret    

008023a1 <devfile_flush>:
{
  8023a1:	f3 0f 1e fb          	endbr32 
  8023a5:	55                   	push   %ebp
  8023a6:	89 e5                	mov    %esp,%ebp
  8023a8:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.flush.req_fileid = fd->fd_file.id;
  8023ab:	8b 45 08             	mov    0x8(%ebp),%eax
  8023ae:	8b 40 0c             	mov    0xc(%eax),%eax
  8023b1:	a3 00 60 80 00       	mov    %eax,0x806000
	return fsipc(FSREQ_FLUSH, NULL);
  8023b6:	ba 00 00 00 00       	mov    $0x0,%edx
  8023bb:	b8 06 00 00 00       	mov    $0x6,%eax
  8023c0:	e8 61 ff ff ff       	call   802326 <fsipc>
}
  8023c5:	c9                   	leave  
  8023c6:	c3                   	ret    

008023c7 <devfile_stat>:
{
  8023c7:	f3 0f 1e fb          	endbr32 
  8023cb:	55                   	push   %ebp
  8023cc:	89 e5                	mov    %esp,%ebp
  8023ce:	53                   	push   %ebx
  8023cf:	83 ec 04             	sub    $0x4,%esp
  8023d2:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	fsipcbuf.stat.req_fileid = fd->fd_file.id;
  8023d5:	8b 45 08             	mov    0x8(%ebp),%eax
  8023d8:	8b 40 0c             	mov    0xc(%eax),%eax
  8023db:	a3 00 60 80 00       	mov    %eax,0x806000
	if ((r = fsipc(FSREQ_STAT, NULL)) < 0)
  8023e0:	ba 00 00 00 00       	mov    $0x0,%edx
  8023e5:	b8 05 00 00 00       	mov    $0x5,%eax
  8023ea:	e8 37 ff ff ff       	call   802326 <fsipc>
  8023ef:	85 c0                	test   %eax,%eax
  8023f1:	78 2c                	js     80241f <devfile_stat+0x58>
	strcpy(st->st_name, fsipcbuf.statRet.ret_name);
  8023f3:	83 ec 08             	sub    $0x8,%esp
  8023f6:	68 00 60 80 00       	push   $0x806000
  8023fb:	53                   	push   %ebx
  8023fc:	e8 63 ee ff ff       	call   801264 <strcpy>
	st->st_size = fsipcbuf.statRet.ret_size;
  802401:	a1 80 60 80 00       	mov    0x806080,%eax
  802406:	89 83 80 00 00 00    	mov    %eax,0x80(%ebx)
	st->st_isdir = fsipcbuf.statRet.ret_isdir;
  80240c:	a1 84 60 80 00       	mov    0x806084,%eax
  802411:	89 83 84 00 00 00    	mov    %eax,0x84(%ebx)
	return 0;
  802417:	83 c4 10             	add    $0x10,%esp
  80241a:	b8 00 00 00 00       	mov    $0x0,%eax
}
  80241f:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  802422:	c9                   	leave  
  802423:	c3                   	ret    

00802424 <devfile_write>:
{
  802424:	f3 0f 1e fb          	endbr32 
  802428:	55                   	push   %ebp
  802429:	89 e5                	mov    %esp,%ebp
  80242b:	83 ec 0c             	sub    $0xc,%esp
  80242e:	8b 45 10             	mov    0x10(%ebp),%eax
  802431:	3d f8 0f 00 00       	cmp    $0xff8,%eax
  802436:	ba f8 0f 00 00       	mov    $0xff8,%edx
  80243b:	0f 47 c2             	cmova  %edx,%eax
	fsipcbuf.write.req_fileid = fd->fd_file.id;
  80243e:	8b 55 08             	mov    0x8(%ebp),%edx
  802441:	8b 52 0c             	mov    0xc(%edx),%edx
  802444:	89 15 00 60 80 00    	mov    %edx,0x806000
	fsipcbuf.write.req_n = n;
  80244a:	a3 04 60 80 00       	mov    %eax,0x806004
	memmove(fsipcbuf.write.req_buf, buf, n);
  80244f:	50                   	push   %eax
  802450:	ff 75 0c             	pushl  0xc(%ebp)
  802453:	68 08 60 80 00       	push   $0x806008
  802458:	e8 bd ef ff ff       	call   80141a <memmove>
	return fsipc(FSREQ_WRITE, NULL);}
  80245d:	ba 00 00 00 00       	mov    $0x0,%edx
  802462:	b8 04 00 00 00       	mov    $0x4,%eax
  802467:	e8 ba fe ff ff       	call   802326 <fsipc>
  80246c:	c9                   	leave  
  80246d:	c3                   	ret    

0080246e <devfile_read>:
{
  80246e:	f3 0f 1e fb          	endbr32 
  802472:	55                   	push   %ebp
  802473:	89 e5                	mov    %esp,%ebp
  802475:	56                   	push   %esi
  802476:	53                   	push   %ebx
  802477:	8b 75 10             	mov    0x10(%ebp),%esi
	fsipcbuf.read.req_fileid = fd->fd_file.id;
  80247a:	8b 45 08             	mov    0x8(%ebp),%eax
  80247d:	8b 40 0c             	mov    0xc(%eax),%eax
  802480:	a3 00 60 80 00       	mov    %eax,0x806000
	fsipcbuf.read.req_n = n;
  802485:	89 35 04 60 80 00    	mov    %esi,0x806004
	if ((r = fsipc(FSREQ_READ, NULL)) < 0)
  80248b:	ba 00 00 00 00       	mov    $0x0,%edx
  802490:	b8 03 00 00 00       	mov    $0x3,%eax
  802495:	e8 8c fe ff ff       	call   802326 <fsipc>
  80249a:	89 c3                	mov    %eax,%ebx
  80249c:	85 c0                	test   %eax,%eax
  80249e:	78 1f                	js     8024bf <devfile_read+0x51>
	assert(r <= n);
  8024a0:	39 f0                	cmp    %esi,%eax
  8024a2:	77 24                	ja     8024c8 <devfile_read+0x5a>
	assert(r <= PGSIZE);
  8024a4:	3d 00 10 00 00       	cmp    $0x1000,%eax
  8024a9:	7f 33                	jg     8024de <devfile_read+0x70>
	memmove(buf, fsipcbuf.readRet.ret_buf, r);
  8024ab:	83 ec 04             	sub    $0x4,%esp
  8024ae:	50                   	push   %eax
  8024af:	68 00 60 80 00       	push   $0x806000
  8024b4:	ff 75 0c             	pushl  0xc(%ebp)
  8024b7:	e8 5e ef ff ff       	call   80141a <memmove>
	return r;
  8024bc:	83 c4 10             	add    $0x10,%esp
}
  8024bf:	89 d8                	mov    %ebx,%eax
  8024c1:	8d 65 f8             	lea    -0x8(%ebp),%esp
  8024c4:	5b                   	pop    %ebx
  8024c5:	5e                   	pop    %esi
  8024c6:	5d                   	pop    %ebp
  8024c7:	c3                   	ret    
	assert(r <= n);
  8024c8:	68 58 3c 80 00       	push   $0x803c58
  8024cd:	68 4f 36 80 00       	push   $0x80364f
  8024d2:	6a 7c                	push   $0x7c
  8024d4:	68 5f 3c 80 00       	push   $0x803c5f
  8024d9:	e8 d2 e5 ff ff       	call   800ab0 <_panic>
	assert(r <= PGSIZE);
  8024de:	68 6a 3c 80 00       	push   $0x803c6a
  8024e3:	68 4f 36 80 00       	push   $0x80364f
  8024e8:	6a 7d                	push   $0x7d
  8024ea:	68 5f 3c 80 00       	push   $0x803c5f
  8024ef:	e8 bc e5 ff ff       	call   800ab0 <_panic>

008024f4 <open>:
{
  8024f4:	f3 0f 1e fb          	endbr32 
  8024f8:	55                   	push   %ebp
  8024f9:	89 e5                	mov    %esp,%ebp
  8024fb:	56                   	push   %esi
  8024fc:	53                   	push   %ebx
  8024fd:	83 ec 1c             	sub    $0x1c,%esp
  802500:	8b 75 08             	mov    0x8(%ebp),%esi
	if (strlen(path) >= MAXPATHLEN)
  802503:	56                   	push   %esi
  802504:	e8 18 ed ff ff       	call   801221 <strlen>
  802509:	83 c4 10             	add    $0x10,%esp
  80250c:	3d ff 03 00 00       	cmp    $0x3ff,%eax
  802511:	7f 6c                	jg     80257f <open+0x8b>
	if ((r = fd_alloc(&fd)) < 0)
  802513:	83 ec 0c             	sub    $0xc,%esp
  802516:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802519:	50                   	push   %eax
  80251a:	e8 67 f8 ff ff       	call   801d86 <fd_alloc>
  80251f:	89 c3                	mov    %eax,%ebx
  802521:	83 c4 10             	add    $0x10,%esp
  802524:	85 c0                	test   %eax,%eax
  802526:	78 3c                	js     802564 <open+0x70>
	strcpy(fsipcbuf.open.req_path, path);
  802528:	83 ec 08             	sub    $0x8,%esp
  80252b:	56                   	push   %esi
  80252c:	68 00 60 80 00       	push   $0x806000
  802531:	e8 2e ed ff ff       	call   801264 <strcpy>
	fsipcbuf.open.req_omode = mode;
  802536:	8b 45 0c             	mov    0xc(%ebp),%eax
  802539:	a3 00 64 80 00       	mov    %eax,0x806400
	if ((r = fsipc(FSREQ_OPEN, fd)) < 0) {
  80253e:	8b 55 f4             	mov    -0xc(%ebp),%edx
  802541:	b8 01 00 00 00       	mov    $0x1,%eax
  802546:	e8 db fd ff ff       	call   802326 <fsipc>
  80254b:	89 c3                	mov    %eax,%ebx
  80254d:	83 c4 10             	add    $0x10,%esp
  802550:	85 c0                	test   %eax,%eax
  802552:	78 19                	js     80256d <open+0x79>
	return fd2num(fd);
  802554:	83 ec 0c             	sub    $0xc,%esp
  802557:	ff 75 f4             	pushl  -0xc(%ebp)
  80255a:	e8 f8 f7 ff ff       	call   801d57 <fd2num>
  80255f:	89 c3                	mov    %eax,%ebx
  802561:	83 c4 10             	add    $0x10,%esp
}
  802564:	89 d8                	mov    %ebx,%eax
  802566:	8d 65 f8             	lea    -0x8(%ebp),%esp
  802569:	5b                   	pop    %ebx
  80256a:	5e                   	pop    %esi
  80256b:	5d                   	pop    %ebp
  80256c:	c3                   	ret    
		fd_close(fd, 0);
  80256d:	83 ec 08             	sub    $0x8,%esp
  802570:	6a 00                	push   $0x0
  802572:	ff 75 f4             	pushl  -0xc(%ebp)
  802575:	e8 10 f9 ff ff       	call   801e8a <fd_close>
		return r;
  80257a:	83 c4 10             	add    $0x10,%esp
  80257d:	eb e5                	jmp    802564 <open+0x70>
		return -E_BAD_PATH;
  80257f:	bb f4 ff ff ff       	mov    $0xfffffff4,%ebx
  802584:	eb de                	jmp    802564 <open+0x70>

00802586 <sync>:


// Synchronize disk with buffer cache
int
sync(void)
{
  802586:	f3 0f 1e fb          	endbr32 
  80258a:	55                   	push   %ebp
  80258b:	89 e5                	mov    %esp,%ebp
  80258d:	83 ec 08             	sub    $0x8,%esp
	// Ask the file server to update the disk
	// by writing any dirty blocks in the buffer cache.

	return fsipc(FSREQ_SYNC, NULL);
  802590:	ba 00 00 00 00       	mov    $0x0,%edx
  802595:	b8 08 00 00 00       	mov    $0x8,%eax
  80259a:	e8 87 fd ff ff       	call   802326 <fsipc>
}
  80259f:	c9                   	leave  
  8025a0:	c3                   	ret    

008025a1 <writebuf>:


static void
writebuf(struct printbuf *b)
{
	if (b->error > 0) {
  8025a1:	83 78 0c 00          	cmpl   $0x0,0xc(%eax)
  8025a5:	7f 01                	jg     8025a8 <writebuf+0x7>
  8025a7:	c3                   	ret    
{
  8025a8:	55                   	push   %ebp
  8025a9:	89 e5                	mov    %esp,%ebp
  8025ab:	53                   	push   %ebx
  8025ac:	83 ec 08             	sub    $0x8,%esp
  8025af:	89 c3                	mov    %eax,%ebx
		ssize_t result = write(b->fd, b->buf, b->idx);
  8025b1:	ff 70 04             	pushl  0x4(%eax)
  8025b4:	8d 40 10             	lea    0x10(%eax),%eax
  8025b7:	50                   	push   %eax
  8025b8:	ff 33                	pushl  (%ebx)
  8025ba:	e8 76 fb ff ff       	call   802135 <write>
		if (result > 0)
  8025bf:	83 c4 10             	add    $0x10,%esp
  8025c2:	85 c0                	test   %eax,%eax
  8025c4:	7e 03                	jle    8025c9 <writebuf+0x28>
			b->result += result;
  8025c6:	01 43 08             	add    %eax,0x8(%ebx)
		if (result != b->idx) // error, or wrote less than supplied
  8025c9:	39 43 04             	cmp    %eax,0x4(%ebx)
  8025cc:	74 0d                	je     8025db <writebuf+0x3a>
			b->error = (result < 0 ? result : 0);
  8025ce:	85 c0                	test   %eax,%eax
  8025d0:	ba 00 00 00 00       	mov    $0x0,%edx
  8025d5:	0f 4f c2             	cmovg  %edx,%eax
  8025d8:	89 43 0c             	mov    %eax,0xc(%ebx)
	}
}
  8025db:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  8025de:	c9                   	leave  
  8025df:	c3                   	ret    

008025e0 <putch>:

static void
putch(int ch, void *thunk)
{
  8025e0:	f3 0f 1e fb          	endbr32 
  8025e4:	55                   	push   %ebp
  8025e5:	89 e5                	mov    %esp,%ebp
  8025e7:	53                   	push   %ebx
  8025e8:	83 ec 04             	sub    $0x4,%esp
  8025eb:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	struct printbuf *b = (struct printbuf *) thunk;
	b->buf[b->idx++] = ch;
  8025ee:	8b 53 04             	mov    0x4(%ebx),%edx
  8025f1:	8d 42 01             	lea    0x1(%edx),%eax
  8025f4:	89 43 04             	mov    %eax,0x4(%ebx)
  8025f7:	8b 4d 08             	mov    0x8(%ebp),%ecx
  8025fa:	88 4c 13 10          	mov    %cl,0x10(%ebx,%edx,1)
	if (b->idx == 256) {
  8025fe:	3d 00 01 00 00       	cmp    $0x100,%eax
  802603:	74 06                	je     80260b <putch+0x2b>
		writebuf(b);
		b->idx = 0;
	}
}
  802605:	83 c4 04             	add    $0x4,%esp
  802608:	5b                   	pop    %ebx
  802609:	5d                   	pop    %ebp
  80260a:	c3                   	ret    
		writebuf(b);
  80260b:	89 d8                	mov    %ebx,%eax
  80260d:	e8 8f ff ff ff       	call   8025a1 <writebuf>
		b->idx = 0;
  802612:	c7 43 04 00 00 00 00 	movl   $0x0,0x4(%ebx)
}
  802619:	eb ea                	jmp    802605 <putch+0x25>

0080261b <vfprintf>:

int
vfprintf(int fd, const char *fmt, va_list ap)
{
  80261b:	f3 0f 1e fb          	endbr32 
  80261f:	55                   	push   %ebp
  802620:	89 e5                	mov    %esp,%ebp
  802622:	81 ec 18 01 00 00    	sub    $0x118,%esp
	struct printbuf b;

	b.fd = fd;
  802628:	8b 45 08             	mov    0x8(%ebp),%eax
  80262b:	89 85 e8 fe ff ff    	mov    %eax,-0x118(%ebp)
	b.idx = 0;
  802631:	c7 85 ec fe ff ff 00 	movl   $0x0,-0x114(%ebp)
  802638:	00 00 00 
	b.result = 0;
  80263b:	c7 85 f0 fe ff ff 00 	movl   $0x0,-0x110(%ebp)
  802642:	00 00 00 
	b.error = 1;
  802645:	c7 85 f4 fe ff ff 01 	movl   $0x1,-0x10c(%ebp)
  80264c:	00 00 00 
	vprintfmt(putch, &b, fmt, ap);
  80264f:	ff 75 10             	pushl  0x10(%ebp)
  802652:	ff 75 0c             	pushl  0xc(%ebp)
  802655:	8d 85 e8 fe ff ff    	lea    -0x118(%ebp),%eax
  80265b:	50                   	push   %eax
  80265c:	68 e0 25 80 00       	push   $0x8025e0
  802661:	e8 34 e6 ff ff       	call   800c9a <vprintfmt>
	if (b.idx > 0)
  802666:	83 c4 10             	add    $0x10,%esp
  802669:	83 bd ec fe ff ff 00 	cmpl   $0x0,-0x114(%ebp)
  802670:	7f 11                	jg     802683 <vfprintf+0x68>
		writebuf(&b);

	return (b.result ? b.result : b.error);
  802672:	8b 85 f0 fe ff ff    	mov    -0x110(%ebp),%eax
  802678:	85 c0                	test   %eax,%eax
  80267a:	0f 44 85 f4 fe ff ff 	cmove  -0x10c(%ebp),%eax
}
  802681:	c9                   	leave  
  802682:	c3                   	ret    
		writebuf(&b);
  802683:	8d 85 e8 fe ff ff    	lea    -0x118(%ebp),%eax
  802689:	e8 13 ff ff ff       	call   8025a1 <writebuf>
  80268e:	eb e2                	jmp    802672 <vfprintf+0x57>

00802690 <fprintf>:

int
fprintf(int fd, const char *fmt, ...)
{
  802690:	f3 0f 1e fb          	endbr32 
  802694:	55                   	push   %ebp
  802695:	89 e5                	mov    %esp,%ebp
  802697:	83 ec 0c             	sub    $0xc,%esp
	va_list ap;
	int cnt;

	va_start(ap, fmt);
  80269a:	8d 45 10             	lea    0x10(%ebp),%eax
	cnt = vfprintf(fd, fmt, ap);
  80269d:	50                   	push   %eax
  80269e:	ff 75 0c             	pushl  0xc(%ebp)
  8026a1:	ff 75 08             	pushl  0x8(%ebp)
  8026a4:	e8 72 ff ff ff       	call   80261b <vfprintf>
	va_end(ap);

	return cnt;
}
  8026a9:	c9                   	leave  
  8026aa:	c3                   	ret    

008026ab <printf>:

int
printf(const char *fmt, ...)
{
  8026ab:	f3 0f 1e fb          	endbr32 
  8026af:	55                   	push   %ebp
  8026b0:	89 e5                	mov    %esp,%ebp
  8026b2:	83 ec 0c             	sub    $0xc,%esp
	va_list ap;
	int cnt;

	va_start(ap, fmt);
  8026b5:	8d 45 0c             	lea    0xc(%ebp),%eax
	cnt = vfprintf(1, fmt, ap);
  8026b8:	50                   	push   %eax
  8026b9:	ff 75 08             	pushl  0x8(%ebp)
  8026bc:	6a 01                	push   $0x1
  8026be:	e8 58 ff ff ff       	call   80261b <vfprintf>
	va_end(ap);

	return cnt;
}
  8026c3:	c9                   	leave  
  8026c4:	c3                   	ret    

008026c5 <spawn>:
// argv: pointer to null-terminated array of pointers to strings,
// 	 which will be passed to the child as its command-line arguments.
// Returns child envid on success, < 0 on failure.
int
spawn(const char *prog, const char **argv)
{
  8026c5:	f3 0f 1e fb          	endbr32 
  8026c9:	55                   	push   %ebp
  8026ca:	89 e5                	mov    %esp,%ebp
  8026cc:	57                   	push   %edi
  8026cd:	56                   	push   %esi
  8026ce:	53                   	push   %ebx
  8026cf:	81 ec 94 02 00 00    	sub    $0x294,%esp
	//   - Call sys_env_set_trapframe(child, &child_tf) to set up the
	//     correct initial eip and esp values in the child.
	//
	//   - Start the child process running with sys_env_set_status().

	if ((r = open(prog, O_RDONLY)) < 0)
  8026d5:	6a 00                	push   $0x0
  8026d7:	ff 75 08             	pushl  0x8(%ebp)
  8026da:	e8 15 fe ff ff       	call   8024f4 <open>
  8026df:	89 85 94 fd ff ff    	mov    %eax,-0x26c(%ebp)
  8026e5:	83 c4 10             	add    $0x10,%esp
  8026e8:	85 c0                	test   %eax,%eax
  8026ea:	0f 88 e5 04 00 00    	js     802bd5 <spawn+0x510>
  8026f0:	89 c1                	mov    %eax,%ecx
		return r;
	fd = r;

	// Read elf header
	elf = (struct Elf*) elf_buf;
	if (readn(fd, elf_buf, sizeof(elf_buf)) != sizeof(elf_buf)
  8026f2:	83 ec 04             	sub    $0x4,%esp
  8026f5:	68 00 02 00 00       	push   $0x200
  8026fa:	8d 85 e8 fd ff ff    	lea    -0x218(%ebp),%eax
  802700:	50                   	push   %eax
  802701:	51                   	push   %ecx
  802702:	e8 e3 f9 ff ff       	call   8020ea <readn>
  802707:	83 c4 10             	add    $0x10,%esp
  80270a:	3d 00 02 00 00       	cmp    $0x200,%eax
  80270f:	75 7e                	jne    80278f <spawn+0xca>
	    || elf->e_magic != ELF_MAGIC) {
  802711:	81 bd e8 fd ff ff 7f 	cmpl   $0x464c457f,-0x218(%ebp)
  802718:	45 4c 46 
  80271b:	75 72                	jne    80278f <spawn+0xca>
  80271d:	b8 07 00 00 00       	mov    $0x7,%eax
  802722:	cd 30                	int    $0x30
  802724:	89 85 74 fd ff ff    	mov    %eax,-0x28c(%ebp)
  80272a:	89 85 88 fd ff ff    	mov    %eax,-0x278(%ebp)
		cprintf("elf magic %08x want %08x\n", elf->e_magic, ELF_MAGIC);
		return -E_NOT_EXEC;
	}

	// Create new child environment
	if ((r = sys_exofork()) < 0)
  802730:	85 c0                	test   %eax,%eax
  802732:	0f 88 91 04 00 00    	js     802bc9 <spawn+0x504>
		return r;
	child = r;

	// Set up trap frame, including initial stack.
	child_tf = envs[ENVX(child)].env_tf;
  802738:	25 ff 03 00 00       	and    $0x3ff,%eax
  80273d:	6b f0 7c             	imul   $0x7c,%eax,%esi
  802740:	81 c6 00 00 c0 ee    	add    $0xeec00000,%esi
  802746:	8d bd a4 fd ff ff    	lea    -0x25c(%ebp),%edi
  80274c:	b9 11 00 00 00       	mov    $0x11,%ecx
  802751:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
	child_tf.tf_eip = elf->e_entry;
  802753:	8b 85 00 fe ff ff    	mov    -0x200(%ebp),%eax
  802759:	89 85 d4 fd ff ff    	mov    %eax,-0x22c(%ebp)
	uintptr_t *argv_store;

	// Count the number of arguments (argc)
	// and the total amount of space needed for strings (string_size).
	string_size = 0;
	for (argc = 0; argv[argc] != 0; argc++)
  80275f:	bb 00 00 00 00       	mov    $0x0,%ebx
	string_size = 0;
  802764:	be 00 00 00 00       	mov    $0x0,%esi
  802769:	8b 7d 0c             	mov    0xc(%ebp),%edi
  80276c:	8d 0c 9d 00 00 00 00 	lea    0x0(,%ebx,4),%ecx
	for (argc = 0; argv[argc] != 0; argc++)
  802773:	8b 04 9f             	mov    (%edi,%ebx,4),%eax
  802776:	85 c0                	test   %eax,%eax
  802778:	74 4d                	je     8027c7 <spawn+0x102>
		string_size += strlen(argv[argc]) + 1;
  80277a:	83 ec 0c             	sub    $0xc,%esp
  80277d:	50                   	push   %eax
  80277e:	e8 9e ea ff ff       	call   801221 <strlen>
  802783:	8d 74 06 01          	lea    0x1(%esi,%eax,1),%esi
	for (argc = 0; argv[argc] != 0; argc++)
  802787:	83 c3 01             	add    $0x1,%ebx
  80278a:	83 c4 10             	add    $0x10,%esp
  80278d:	eb dd                	jmp    80276c <spawn+0xa7>
		close(fd);
  80278f:	83 ec 0c             	sub    $0xc,%esp
  802792:	ff b5 94 fd ff ff    	pushl  -0x26c(%ebp)
  802798:	e8 78 f7 ff ff       	call   801f15 <close>
		cprintf("elf magic %08x want %08x\n", elf->e_magic, ELF_MAGIC);
  80279d:	83 c4 0c             	add    $0xc,%esp
  8027a0:	68 7f 45 4c 46       	push   $0x464c457f
  8027a5:	ff b5 e8 fd ff ff    	pushl  -0x218(%ebp)
  8027ab:	68 76 3c 80 00       	push   $0x803c76
  8027b0:	e8 e2 e3 ff ff       	call   800b97 <cprintf>
		return -E_NOT_EXEC;
  8027b5:	83 c4 10             	add    $0x10,%esp
  8027b8:	c7 85 94 fd ff ff f2 	movl   $0xfffffff2,-0x26c(%ebp)
  8027bf:	ff ff ff 
  8027c2:	e9 0e 04 00 00       	jmp    802bd5 <spawn+0x510>
  8027c7:	89 9d 84 fd ff ff    	mov    %ebx,-0x27c(%ebp)
  8027cd:	89 8d 80 fd ff ff    	mov    %ecx,-0x280(%ebp)
	// Determine where to place the strings and the argv array.
	// Set up pointers into the temporary page 'UTEMP'; we'll map a page
	// there later, then remap that page into the child environment
	// at (USTACKTOP - PGSIZE).
	// strings is the topmost thing on the stack.
	string_store = (char*) UTEMP + PGSIZE - string_size;
  8027d3:	bf 00 10 40 00       	mov    $0x401000,%edi
  8027d8:	29 f7                	sub    %esi,%edi
	// argv is below that.  There's one argument pointer per argument, plus
	// a null pointer.
	argv_store = (uintptr_t*) (ROUNDDOWN(string_store, 4) - 4 * (argc + 1));
  8027da:	89 fa                	mov    %edi,%edx
  8027dc:	83 e2 fc             	and    $0xfffffffc,%edx
  8027df:	8d 04 9d 04 00 00 00 	lea    0x4(,%ebx,4),%eax
  8027e6:	29 c2                	sub    %eax,%edx
  8027e8:	89 95 90 fd ff ff    	mov    %edx,-0x270(%ebp)

	// Make sure that argv, strings, and the 2 words that hold 'argc'
	// and 'argv' themselves will all fit in a single stack page.
	if ((void*) (argv_store - 2) < (void*) UTEMP)
  8027ee:	8d 42 f8             	lea    -0x8(%edx),%eax
  8027f1:	3d ff ff 3f 00       	cmp    $0x3fffff,%eax
  8027f6:	0f 86 fc 03 00 00    	jbe    802bf8 <spawn+0x533>
		return -E_NO_MEM;

	// Allocate the single stack page at UTEMP.
	if ((r = sys_page_alloc(0, (void*) UTEMP, PTE_P|PTE_U|PTE_W)) < 0)
  8027fc:	83 ec 04             	sub    $0x4,%esp
  8027ff:	6a 07                	push   $0x7
  802801:	68 00 00 40 00       	push   $0x400000
  802806:	6a 00                	push   $0x0
  802808:	e8 99 ee ff ff       	call   8016a6 <sys_page_alloc>
  80280d:	83 c4 10             	add    $0x10,%esp
  802810:	85 c0                	test   %eax,%eax
  802812:	0f 88 e5 03 00 00    	js     802bfd <spawn+0x538>
	//	  (Again, argv should use an address valid in the child's
	//	  environment.)
	//
	//	* Set *init_esp to the initial stack pointer for the child,
	//	  (Again, use an address valid in the child's environment.)
	for (i = 0; i < argc; i++) {
  802818:	be 00 00 00 00       	mov    $0x0,%esi
  80281d:	89 9d 8c fd ff ff    	mov    %ebx,-0x274(%ebp)
  802823:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  802826:	eb 30                	jmp    802858 <spawn+0x193>
		argv_store[i] = UTEMP2USTACK(string_store);
  802828:	8d 87 00 d0 7f ee    	lea    -0x11803000(%edi),%eax
  80282e:	8b 8d 90 fd ff ff    	mov    -0x270(%ebp),%ecx
  802834:	89 04 b1             	mov    %eax,(%ecx,%esi,4)
		strcpy(string_store, argv[i]);
  802837:	83 ec 08             	sub    $0x8,%esp
  80283a:	ff 34 b3             	pushl  (%ebx,%esi,4)
  80283d:	57                   	push   %edi
  80283e:	e8 21 ea ff ff       	call   801264 <strcpy>
		string_store += strlen(argv[i]) + 1;
  802843:	83 c4 04             	add    $0x4,%esp
  802846:	ff 34 b3             	pushl  (%ebx,%esi,4)
  802849:	e8 d3 e9 ff ff       	call   801221 <strlen>
  80284e:	8d 7c 07 01          	lea    0x1(%edi,%eax,1),%edi
	for (i = 0; i < argc; i++) {
  802852:	83 c6 01             	add    $0x1,%esi
  802855:	83 c4 10             	add    $0x10,%esp
  802858:	39 b5 8c fd ff ff    	cmp    %esi,-0x274(%ebp)
  80285e:	7f c8                	jg     802828 <spawn+0x163>
	}
	argv_store[argc] = 0;
  802860:	8b 85 90 fd ff ff    	mov    -0x270(%ebp),%eax
  802866:	8b 8d 80 fd ff ff    	mov    -0x280(%ebp),%ecx
  80286c:	c7 04 08 00 00 00 00 	movl   $0x0,(%eax,%ecx,1)
	assert(string_store == (char*)UTEMP + PGSIZE);
  802873:	81 ff 00 10 40 00    	cmp    $0x401000,%edi
  802879:	0f 85 86 00 00 00    	jne    802905 <spawn+0x240>

	argv_store[-1] = UTEMP2USTACK(argv_store);
  80287f:	8b 95 90 fd ff ff    	mov    -0x270(%ebp),%edx
  802885:	8d 82 00 d0 7f ee    	lea    -0x11803000(%edx),%eax
  80288b:	89 42 fc             	mov    %eax,-0x4(%edx)
	argv_store[-2] = argc;
  80288e:	89 d0                	mov    %edx,%eax
  802890:	8b 8d 84 fd ff ff    	mov    -0x27c(%ebp),%ecx
  802896:	89 4a f8             	mov    %ecx,-0x8(%edx)

	*init_esp = UTEMP2USTACK(&argv_store[-2]);
  802899:	2d 08 30 80 11       	sub    $0x11803008,%eax
  80289e:	89 85 e0 fd ff ff    	mov    %eax,-0x220(%ebp)

	// After completing the stack, map it into the child's address space
	// and unmap it from ours!
	if ((r = sys_page_map(0, UTEMP, child, (void*) (USTACKTOP - PGSIZE), PTE_P | PTE_U | PTE_W)) < 0)
  8028a4:	83 ec 0c             	sub    $0xc,%esp
  8028a7:	6a 07                	push   $0x7
  8028a9:	68 00 d0 bf ee       	push   $0xeebfd000
  8028ae:	ff b5 74 fd ff ff    	pushl  -0x28c(%ebp)
  8028b4:	68 00 00 40 00       	push   $0x400000
  8028b9:	6a 00                	push   $0x0
  8028bb:	e8 2d ee ff ff       	call   8016ed <sys_page_map>
  8028c0:	89 c3                	mov    %eax,%ebx
  8028c2:	83 c4 20             	add    $0x20,%esp
  8028c5:	85 c0                	test   %eax,%eax
  8028c7:	0f 88 38 03 00 00    	js     802c05 <spawn+0x540>
		goto error;
	if ((r = sys_page_unmap(0, UTEMP)) < 0)
  8028cd:	83 ec 08             	sub    $0x8,%esp
  8028d0:	68 00 00 40 00       	push   $0x400000
  8028d5:	6a 00                	push   $0x0
  8028d7:	e8 57 ee ff ff       	call   801733 <sys_page_unmap>
  8028dc:	89 c3                	mov    %eax,%ebx
  8028de:	83 c4 10             	add    $0x10,%esp
  8028e1:	85 c0                	test   %eax,%eax
  8028e3:	0f 88 1c 03 00 00    	js     802c05 <spawn+0x540>
	ph = (struct Proghdr*) (elf_buf + elf->e_phoff);
  8028e9:	8b 85 04 fe ff ff    	mov    -0x1fc(%ebp),%eax
  8028ef:	8d b4 05 e8 fd ff ff 	lea    -0x218(%ebp,%eax,1),%esi
	for (i = 0; i < elf->e_phnum; i++, ph++) {
  8028f6:	c7 85 84 fd ff ff 00 	movl   $0x0,-0x27c(%ebp)
  8028fd:	00 00 00 
  802900:	e9 4f 01 00 00       	jmp    802a54 <spawn+0x38f>
	assert(string_store == (char*)UTEMP + PGSIZE);
  802905:	68 ec 3c 80 00       	push   $0x803cec
  80290a:	68 4f 36 80 00       	push   $0x80364f
  80290f:	68 f2 00 00 00       	push   $0xf2
  802914:	68 90 3c 80 00       	push   $0x803c90
  802919:	e8 92 e1 ff ff       	call   800ab0 <_panic>
			// allocate a blank page
			if ((r = sys_page_alloc(child, (void*) (va + i), perm)) < 0)
				return r;
		} else {
			// from file
			if ((r = sys_page_alloc(0, UTEMP, PTE_P|PTE_U|PTE_W)) < 0)
  80291e:	83 ec 04             	sub    $0x4,%esp
  802921:	6a 07                	push   $0x7
  802923:	68 00 00 40 00       	push   $0x400000
  802928:	6a 00                	push   $0x0
  80292a:	e8 77 ed ff ff       	call   8016a6 <sys_page_alloc>
  80292f:	83 c4 10             	add    $0x10,%esp
  802932:	85 c0                	test   %eax,%eax
  802934:	0f 88 a9 02 00 00    	js     802be3 <spawn+0x51e>
				return r;
			if ((r = seek(fd, fileoffset + i)) < 0)
  80293a:	83 ec 08             	sub    $0x8,%esp
  80293d:	8b 85 80 fd ff ff    	mov    -0x280(%ebp),%eax
  802943:	01 f0                	add    %esi,%eax
  802945:	50                   	push   %eax
  802946:	ff b5 94 fd ff ff    	pushl  -0x26c(%ebp)
  80294c:	e8 6a f8 ff ff       	call   8021bb <seek>
  802951:	83 c4 10             	add    $0x10,%esp
  802954:	85 c0                	test   %eax,%eax
  802956:	0f 88 8e 02 00 00    	js     802bea <spawn+0x525>
				return r;
			if ((r = readn(fd, UTEMP, MIN(PGSIZE, filesz-i))) < 0)
  80295c:	83 ec 04             	sub    $0x4,%esp
  80295f:	8b 85 90 fd ff ff    	mov    -0x270(%ebp),%eax
  802965:	29 f0                	sub    %esi,%eax
  802967:	3d 00 10 00 00       	cmp    $0x1000,%eax
  80296c:	b9 00 10 00 00       	mov    $0x1000,%ecx
  802971:	0f 47 c1             	cmova  %ecx,%eax
  802974:	50                   	push   %eax
  802975:	68 00 00 40 00       	push   $0x400000
  80297a:	ff b5 94 fd ff ff    	pushl  -0x26c(%ebp)
  802980:	e8 65 f7 ff ff       	call   8020ea <readn>
  802985:	83 c4 10             	add    $0x10,%esp
  802988:	85 c0                	test   %eax,%eax
  80298a:	0f 88 61 02 00 00    	js     802bf1 <spawn+0x52c>
				return r;
			if ((r = sys_page_map(0, UTEMP, child, (void*) (va + i), perm)) < 0)
  802990:	83 ec 0c             	sub    $0xc,%esp
  802993:	ff b5 8c fd ff ff    	pushl  -0x274(%ebp)
  802999:	53                   	push   %ebx
  80299a:	ff b5 88 fd ff ff    	pushl  -0x278(%ebp)
  8029a0:	68 00 00 40 00       	push   $0x400000
  8029a5:	6a 00                	push   $0x0
  8029a7:	e8 41 ed ff ff       	call   8016ed <sys_page_map>
  8029ac:	83 c4 20             	add    $0x20,%esp
  8029af:	85 c0                	test   %eax,%eax
  8029b1:	78 7c                	js     802a2f <spawn+0x36a>
				panic("spawn: sys_page_map data: %e", r);
			sys_page_unmap(0, UTEMP);
  8029b3:	83 ec 08             	sub    $0x8,%esp
  8029b6:	68 00 00 40 00       	push   $0x400000
  8029bb:	6a 00                	push   $0x0
  8029bd:	e8 71 ed ff ff       	call   801733 <sys_page_unmap>
  8029c2:	83 c4 10             	add    $0x10,%esp
	for (i = 0; i < memsz; i += PGSIZE) {
  8029c5:	81 c7 00 10 00 00    	add    $0x1000,%edi
  8029cb:	81 c3 00 10 00 00    	add    $0x1000,%ebx
  8029d1:	89 fe                	mov    %edi,%esi
  8029d3:	39 bd 7c fd ff ff    	cmp    %edi,-0x284(%ebp)
  8029d9:	76 69                	jbe    802a44 <spawn+0x37f>
		if (i >= filesz) {
  8029db:	39 bd 90 fd ff ff    	cmp    %edi,-0x270(%ebp)
  8029e1:	0f 87 37 ff ff ff    	ja     80291e <spawn+0x259>
			if ((r = sys_page_alloc(child, (void*) (va + i), perm)) < 0)
  8029e7:	83 ec 04             	sub    $0x4,%esp
  8029ea:	ff b5 8c fd ff ff    	pushl  -0x274(%ebp)
  8029f0:	53                   	push   %ebx
  8029f1:	ff b5 88 fd ff ff    	pushl  -0x278(%ebp)
  8029f7:	e8 aa ec ff ff       	call   8016a6 <sys_page_alloc>
  8029fc:	83 c4 10             	add    $0x10,%esp
  8029ff:	85 c0                	test   %eax,%eax
  802a01:	79 c2                	jns    8029c5 <spawn+0x300>
  802a03:	89 c7                	mov    %eax,%edi
	sys_env_destroy(child);
  802a05:	83 ec 0c             	sub    $0xc,%esp
  802a08:	ff b5 74 fd ff ff    	pushl  -0x28c(%ebp)
  802a0e:	e8 08 ec ff ff       	call   80161b <sys_env_destroy>
	close(fd);
  802a13:	83 c4 04             	add    $0x4,%esp
  802a16:	ff b5 94 fd ff ff    	pushl  -0x26c(%ebp)
  802a1c:	e8 f4 f4 ff ff       	call   801f15 <close>
	return r;
  802a21:	83 c4 10             	add    $0x10,%esp
  802a24:	89 bd 94 fd ff ff    	mov    %edi,-0x26c(%ebp)
  802a2a:	e9 a6 01 00 00       	jmp    802bd5 <spawn+0x510>
				panic("spawn: sys_page_map data: %e", r);
  802a2f:	50                   	push   %eax
  802a30:	68 9c 3c 80 00       	push   $0x803c9c
  802a35:	68 25 01 00 00       	push   $0x125
  802a3a:	68 90 3c 80 00       	push   $0x803c90
  802a3f:	e8 6c e0 ff ff       	call   800ab0 <_panic>
  802a44:	8b b5 78 fd ff ff    	mov    -0x288(%ebp),%esi
	for (i = 0; i < elf->e_phnum; i++, ph++) {
  802a4a:	83 85 84 fd ff ff 01 	addl   $0x1,-0x27c(%ebp)
  802a51:	83 c6 20             	add    $0x20,%esi
  802a54:	0f b7 85 14 fe ff ff 	movzwl -0x1ec(%ebp),%eax
  802a5b:	3b 85 84 fd ff ff    	cmp    -0x27c(%ebp),%eax
  802a61:	7e 6d                	jle    802ad0 <spawn+0x40b>
		if (ph->p_type != ELF_PROG_LOAD)
  802a63:	83 3e 01             	cmpl   $0x1,(%esi)
  802a66:	75 e2                	jne    802a4a <spawn+0x385>
		if (ph->p_flags & ELF_PROG_FLAG_WRITE)
  802a68:	8b 46 18             	mov    0x18(%esi),%eax
  802a6b:	83 e0 02             	and    $0x2,%eax
			perm |= PTE_W;
  802a6e:	83 f8 01             	cmp    $0x1,%eax
  802a71:	19 c0                	sbb    %eax,%eax
  802a73:	83 e0 fe             	and    $0xfffffffe,%eax
  802a76:	83 c0 07             	add    $0x7,%eax
  802a79:	89 85 8c fd ff ff    	mov    %eax,-0x274(%ebp)
		if ((r = map_segment(child, ph->p_va, ph->p_memsz,
  802a7f:	8b 4e 04             	mov    0x4(%esi),%ecx
  802a82:	89 8d 80 fd ff ff    	mov    %ecx,-0x280(%ebp)
  802a88:	8b 56 10             	mov    0x10(%esi),%edx
  802a8b:	89 95 90 fd ff ff    	mov    %edx,-0x270(%ebp)
  802a91:	8b 7e 14             	mov    0x14(%esi),%edi
  802a94:	89 bd 7c fd ff ff    	mov    %edi,-0x284(%ebp)
  802a9a:	8b 5e 08             	mov    0x8(%esi),%ebx
	if ((i = PGOFF(va))) {
  802a9d:	89 d8                	mov    %ebx,%eax
  802a9f:	25 ff 0f 00 00       	and    $0xfff,%eax
  802aa4:	74 1a                	je     802ac0 <spawn+0x3fb>
		va -= i;
  802aa6:	29 c3                	sub    %eax,%ebx
		memsz += i;
  802aa8:	01 c7                	add    %eax,%edi
  802aaa:	89 bd 7c fd ff ff    	mov    %edi,-0x284(%ebp)
		filesz += i;
  802ab0:	01 c2                	add    %eax,%edx
  802ab2:	89 95 90 fd ff ff    	mov    %edx,-0x270(%ebp)
		fileoffset -= i;
  802ab8:	29 c1                	sub    %eax,%ecx
  802aba:	89 8d 80 fd ff ff    	mov    %ecx,-0x280(%ebp)
	for (i = 0; i < memsz; i += PGSIZE) {
  802ac0:	bf 00 00 00 00       	mov    $0x0,%edi
  802ac5:	89 b5 78 fd ff ff    	mov    %esi,-0x288(%ebp)
  802acb:	e9 01 ff ff ff       	jmp    8029d1 <spawn+0x30c>
	close(fd);
  802ad0:	83 ec 0c             	sub    $0xc,%esp
  802ad3:	ff b5 94 fd ff ff    	pushl  -0x26c(%ebp)
  802ad9:	e8 37 f4 ff ff       	call   801f15 <close>
  802ade:	83 c4 10             	add    $0x10,%esp
static int
copy_shared_pages(envid_t child)
{
	// LAB 5: Your code here.
	uintptr_t addr;
	for (addr = 0; addr < UTOP; addr += PGSIZE) {
  802ae1:	bb 00 00 00 00       	mov    $0x0,%ebx
  802ae6:	8b b5 88 fd ff ff    	mov    -0x278(%ebp),%esi
  802aec:	eb 2b                	jmp    802b19 <spawn+0x454>
		if ((uvpd[PDX(addr)] & PTE_P) && (uvpt[PGNUM(addr)] & PTE_P) &&
				(uvpt[PGNUM(addr)] & PTE_U) && (uvpt[PGNUM(addr)] & PTE_SHARE)) {
            sys_page_map(0, (void*)addr, child, (void*)addr, (uvpt[PGNUM(addr)] & PTE_SYSCALL));
  802aee:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
  802af5:	83 ec 0c             	sub    $0xc,%esp
  802af8:	25 07 0e 00 00       	and    $0xe07,%eax
  802afd:	50                   	push   %eax
  802afe:	53                   	push   %ebx
  802aff:	56                   	push   %esi
  802b00:	53                   	push   %ebx
  802b01:	6a 00                	push   $0x0
  802b03:	e8 e5 eb ff ff       	call   8016ed <sys_page_map>
  802b08:	83 c4 20             	add    $0x20,%esp
	for (addr = 0; addr < UTOP; addr += PGSIZE) {
  802b0b:	81 c3 00 10 00 00    	add    $0x1000,%ebx
  802b11:	81 fb 00 00 c0 ee    	cmp    $0xeec00000,%ebx
  802b17:	74 3b                	je     802b54 <spawn+0x48f>
		if ((uvpd[PDX(addr)] & PTE_P) && (uvpt[PGNUM(addr)] & PTE_P) &&
  802b19:	89 d8                	mov    %ebx,%eax
  802b1b:	c1 e8 16             	shr    $0x16,%eax
  802b1e:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  802b25:	a8 01                	test   $0x1,%al
  802b27:	74 e2                	je     802b0b <spawn+0x446>
  802b29:	89 d8                	mov    %ebx,%eax
  802b2b:	c1 e8 0c             	shr    $0xc,%eax
  802b2e:	8b 14 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%edx
  802b35:	f6 c2 01             	test   $0x1,%dl
  802b38:	74 d1                	je     802b0b <spawn+0x446>
				(uvpt[PGNUM(addr)] & PTE_U) && (uvpt[PGNUM(addr)] & PTE_SHARE)) {
  802b3a:	8b 14 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%edx
		if ((uvpd[PDX(addr)] & PTE_P) && (uvpt[PGNUM(addr)] & PTE_P) &&
  802b41:	f6 c2 04             	test   $0x4,%dl
  802b44:	74 c5                	je     802b0b <spawn+0x446>
				(uvpt[PGNUM(addr)] & PTE_U) && (uvpt[PGNUM(addr)] & PTE_SHARE)) {
  802b46:	8b 14 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%edx
  802b4d:	f6 c6 04             	test   $0x4,%dh
  802b50:	74 b9                	je     802b0b <spawn+0x446>
  802b52:	eb 9a                	jmp    802aee <spawn+0x429>
	child_tf.tf_eflags |= FL_IOPL_3;   // devious: see user/faultio.c
  802b54:	81 8d dc fd ff ff 00 	orl    $0x3000,-0x224(%ebp)
  802b5b:	30 00 00 
	if ((r = sys_env_set_trapframe(child, &child_tf)) < 0)
  802b5e:	83 ec 08             	sub    $0x8,%esp
  802b61:	8d 85 a4 fd ff ff    	lea    -0x25c(%ebp),%eax
  802b67:	50                   	push   %eax
  802b68:	ff b5 74 fd ff ff    	pushl  -0x28c(%ebp)
  802b6e:	e8 4c ec ff ff       	call   8017bf <sys_env_set_trapframe>
  802b73:	83 c4 10             	add    $0x10,%esp
  802b76:	85 c0                	test   %eax,%eax
  802b78:	78 25                	js     802b9f <spawn+0x4da>
	if ((r = sys_env_set_status(child, ENV_RUNNABLE)) < 0)
  802b7a:	83 ec 08             	sub    $0x8,%esp
  802b7d:	6a 02                	push   $0x2
  802b7f:	ff b5 74 fd ff ff    	pushl  -0x28c(%ebp)
  802b85:	e8 ef eb ff ff       	call   801779 <sys_env_set_status>
  802b8a:	83 c4 10             	add    $0x10,%esp
  802b8d:	85 c0                	test   %eax,%eax
  802b8f:	78 23                	js     802bb4 <spawn+0x4ef>
	return child;
  802b91:	8b 85 74 fd ff ff    	mov    -0x28c(%ebp),%eax
  802b97:	89 85 94 fd ff ff    	mov    %eax,-0x26c(%ebp)
  802b9d:	eb 36                	jmp    802bd5 <spawn+0x510>
		panic("sys_env_set_trapframe: %e", r);
  802b9f:	50                   	push   %eax
  802ba0:	68 b9 3c 80 00       	push   $0x803cb9
  802ba5:	68 86 00 00 00       	push   $0x86
  802baa:	68 90 3c 80 00       	push   $0x803c90
  802baf:	e8 fc de ff ff       	call   800ab0 <_panic>
		panic("sys_env_set_status: %e", r);
  802bb4:	50                   	push   %eax
  802bb5:	68 d3 3c 80 00       	push   $0x803cd3
  802bba:	68 89 00 00 00       	push   $0x89
  802bbf:	68 90 3c 80 00       	push   $0x803c90
  802bc4:	e8 e7 de ff ff       	call   800ab0 <_panic>
		return r;
  802bc9:	8b 85 74 fd ff ff    	mov    -0x28c(%ebp),%eax
  802bcf:	89 85 94 fd ff ff    	mov    %eax,-0x26c(%ebp)
}
  802bd5:	8b 85 94 fd ff ff    	mov    -0x26c(%ebp),%eax
  802bdb:	8d 65 f4             	lea    -0xc(%ebp),%esp
  802bde:	5b                   	pop    %ebx
  802bdf:	5e                   	pop    %esi
  802be0:	5f                   	pop    %edi
  802be1:	5d                   	pop    %ebp
  802be2:	c3                   	ret    
  802be3:	89 c7                	mov    %eax,%edi
  802be5:	e9 1b fe ff ff       	jmp    802a05 <spawn+0x340>
  802bea:	89 c7                	mov    %eax,%edi
  802bec:	e9 14 fe ff ff       	jmp    802a05 <spawn+0x340>
  802bf1:	89 c7                	mov    %eax,%edi
  802bf3:	e9 0d fe ff ff       	jmp    802a05 <spawn+0x340>
		return -E_NO_MEM;
  802bf8:	b8 fc ff ff ff       	mov    $0xfffffffc,%eax
	for (addr = 0; addr < UTOP; addr += PGSIZE) {
  802bfd:	89 85 94 fd ff ff    	mov    %eax,-0x26c(%ebp)
  802c03:	eb d0                	jmp    802bd5 <spawn+0x510>
	sys_page_unmap(0, UTEMP);
  802c05:	83 ec 08             	sub    $0x8,%esp
  802c08:	68 00 00 40 00       	push   $0x400000
  802c0d:	6a 00                	push   $0x0
  802c0f:	e8 1f eb ff ff       	call   801733 <sys_page_unmap>
  802c14:	83 c4 10             	add    $0x10,%esp
  802c17:	89 9d 94 fd ff ff    	mov    %ebx,-0x26c(%ebp)
  802c1d:	eb b6                	jmp    802bd5 <spawn+0x510>

00802c1f <spawnl>:
{
  802c1f:	f3 0f 1e fb          	endbr32 
  802c23:	55                   	push   %ebp
  802c24:	89 e5                	mov    %esp,%ebp
  802c26:	57                   	push   %edi
  802c27:	56                   	push   %esi
  802c28:	53                   	push   %ebx
  802c29:	83 ec 0c             	sub    $0xc,%esp
	va_start(vl, arg0);
  802c2c:	8d 55 10             	lea    0x10(%ebp),%edx
	int argc=0;
  802c2f:	b8 00 00 00 00       	mov    $0x0,%eax
	while(va_arg(vl, void *) != NULL)
  802c34:	8d 4a 04             	lea    0x4(%edx),%ecx
  802c37:	83 3a 00             	cmpl   $0x0,(%edx)
  802c3a:	74 07                	je     802c43 <spawnl+0x24>
		argc++;
  802c3c:	83 c0 01             	add    $0x1,%eax
	while(va_arg(vl, void *) != NULL)
  802c3f:	89 ca                	mov    %ecx,%edx
  802c41:	eb f1                	jmp    802c34 <spawnl+0x15>
	const char *argv[argc+2];
  802c43:	8d 14 85 17 00 00 00 	lea    0x17(,%eax,4),%edx
  802c4a:	89 d1                	mov    %edx,%ecx
  802c4c:	83 e1 f0             	and    $0xfffffff0,%ecx
  802c4f:	81 e2 00 f0 ff ff    	and    $0xfffff000,%edx
  802c55:	89 e6                	mov    %esp,%esi
  802c57:	29 d6                	sub    %edx,%esi
  802c59:	89 f2                	mov    %esi,%edx
  802c5b:	39 d4                	cmp    %edx,%esp
  802c5d:	74 10                	je     802c6f <spawnl+0x50>
  802c5f:	81 ec 00 10 00 00    	sub    $0x1000,%esp
  802c65:	83 8c 24 fc 0f 00 00 	orl    $0x0,0xffc(%esp)
  802c6c:	00 
  802c6d:	eb ec                	jmp    802c5b <spawnl+0x3c>
  802c6f:	89 ca                	mov    %ecx,%edx
  802c71:	81 e2 ff 0f 00 00    	and    $0xfff,%edx
  802c77:	29 d4                	sub    %edx,%esp
  802c79:	85 d2                	test   %edx,%edx
  802c7b:	74 05                	je     802c82 <spawnl+0x63>
  802c7d:	83 4c 14 fc 00       	orl    $0x0,-0x4(%esp,%edx,1)
  802c82:	8d 74 24 03          	lea    0x3(%esp),%esi
  802c86:	89 f2                	mov    %esi,%edx
  802c88:	c1 ea 02             	shr    $0x2,%edx
  802c8b:	83 e6 fc             	and    $0xfffffffc,%esi
  802c8e:	89 f3                	mov    %esi,%ebx
	argv[0] = arg0;
  802c90:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  802c93:	89 0c 95 00 00 00 00 	mov    %ecx,0x0(,%edx,4)
	argv[argc+1] = NULL;
  802c9a:	c7 44 86 04 00 00 00 	movl   $0x0,0x4(%esi,%eax,4)
  802ca1:	00 
	va_start(vl, arg0);
  802ca2:	8d 4d 10             	lea    0x10(%ebp),%ecx
  802ca5:	89 c2                	mov    %eax,%edx
	for(i=0;i<argc;i++)
  802ca7:	b8 00 00 00 00       	mov    $0x0,%eax
  802cac:	eb 0b                	jmp    802cb9 <spawnl+0x9a>
		argv[i+1] = va_arg(vl, const char *);
  802cae:	83 c0 01             	add    $0x1,%eax
  802cb1:	8b 39                	mov    (%ecx),%edi
  802cb3:	89 3c 83             	mov    %edi,(%ebx,%eax,4)
  802cb6:	8d 49 04             	lea    0x4(%ecx),%ecx
	for(i=0;i<argc;i++)
  802cb9:	39 d0                	cmp    %edx,%eax
  802cbb:	75 f1                	jne    802cae <spawnl+0x8f>
	return spawn(prog, argv);
  802cbd:	83 ec 08             	sub    $0x8,%esp
  802cc0:	56                   	push   %esi
  802cc1:	ff 75 08             	pushl  0x8(%ebp)
  802cc4:	e8 fc f9 ff ff       	call   8026c5 <spawn>
}
  802cc9:	8d 65 f4             	lea    -0xc(%ebp),%esp
  802ccc:	5b                   	pop    %ebx
  802ccd:	5e                   	pop    %esi
  802cce:	5f                   	pop    %edi
  802ccf:	5d                   	pop    %ebp
  802cd0:	c3                   	ret    

00802cd1 <devpipe_stat>:
	return i;
}

static int
devpipe_stat(struct Fd *fd, struct Stat *stat)
{
  802cd1:	f3 0f 1e fb          	endbr32 
  802cd5:	55                   	push   %ebp
  802cd6:	89 e5                	mov    %esp,%ebp
  802cd8:	56                   	push   %esi
  802cd9:	53                   	push   %ebx
  802cda:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	struct Pipe *p = (struct Pipe*) fd2data(fd);
  802cdd:	83 ec 0c             	sub    $0xc,%esp
  802ce0:	ff 75 08             	pushl  0x8(%ebp)
  802ce3:	e8 83 f0 ff ff       	call   801d6b <fd2data>
  802ce8:	89 c6                	mov    %eax,%esi
	strcpy(stat->st_name, "<pipe>");
  802cea:	83 c4 08             	add    $0x8,%esp
  802ced:	68 12 3d 80 00       	push   $0x803d12
  802cf2:	53                   	push   %ebx
  802cf3:	e8 6c e5 ff ff       	call   801264 <strcpy>
	stat->st_size = p->p_wpos - p->p_rpos;
  802cf8:	8b 46 04             	mov    0x4(%esi),%eax
  802cfb:	2b 06                	sub    (%esi),%eax
  802cfd:	89 83 80 00 00 00    	mov    %eax,0x80(%ebx)
	stat->st_isdir = 0;
  802d03:	c7 83 84 00 00 00 00 	movl   $0x0,0x84(%ebx)
  802d0a:	00 00 00 
	stat->st_dev = &devpipe;
  802d0d:	c7 83 88 00 00 00 3c 	movl   $0x80403c,0x88(%ebx)
  802d14:	40 80 00 
	return 0;
}
  802d17:	b8 00 00 00 00       	mov    $0x0,%eax
  802d1c:	8d 65 f8             	lea    -0x8(%ebp),%esp
  802d1f:	5b                   	pop    %ebx
  802d20:	5e                   	pop    %esi
  802d21:	5d                   	pop    %ebp
  802d22:	c3                   	ret    

00802d23 <devpipe_close>:

static int
devpipe_close(struct Fd *fd)
{
  802d23:	f3 0f 1e fb          	endbr32 
  802d27:	55                   	push   %ebp
  802d28:	89 e5                	mov    %esp,%ebp
  802d2a:	53                   	push   %ebx
  802d2b:	83 ec 0c             	sub    $0xc,%esp
  802d2e:	8b 5d 08             	mov    0x8(%ebp),%ebx
	(void) sys_page_unmap(0, fd);
  802d31:	53                   	push   %ebx
  802d32:	6a 00                	push   $0x0
  802d34:	e8 fa e9 ff ff       	call   801733 <sys_page_unmap>
	return sys_page_unmap(0, fd2data(fd));
  802d39:	89 1c 24             	mov    %ebx,(%esp)
  802d3c:	e8 2a f0 ff ff       	call   801d6b <fd2data>
  802d41:	83 c4 08             	add    $0x8,%esp
  802d44:	50                   	push   %eax
  802d45:	6a 00                	push   $0x0
  802d47:	e8 e7 e9 ff ff       	call   801733 <sys_page_unmap>
}
  802d4c:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  802d4f:	c9                   	leave  
  802d50:	c3                   	ret    

00802d51 <_pipeisclosed>:
{
  802d51:	55                   	push   %ebp
  802d52:	89 e5                	mov    %esp,%ebp
  802d54:	57                   	push   %edi
  802d55:	56                   	push   %esi
  802d56:	53                   	push   %ebx
  802d57:	83 ec 1c             	sub    $0x1c,%esp
  802d5a:	89 c7                	mov    %eax,%edi
  802d5c:	89 d6                	mov    %edx,%esi
		n = thisenv->env_runs;
  802d5e:	a1 24 54 80 00       	mov    0x805424,%eax
  802d63:	8b 58 58             	mov    0x58(%eax),%ebx
		ret = pageref(fd) == pageref(p);
  802d66:	83 ec 0c             	sub    $0xc,%esp
  802d69:	57                   	push   %edi
  802d6a:	e8 d2 04 00 00       	call   803241 <pageref>
  802d6f:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  802d72:	89 34 24             	mov    %esi,(%esp)
  802d75:	e8 c7 04 00 00       	call   803241 <pageref>
		nn = thisenv->env_runs;
  802d7a:	8b 15 24 54 80 00    	mov    0x805424,%edx
  802d80:	8b 4a 58             	mov    0x58(%edx),%ecx
		if (n == nn)
  802d83:	83 c4 10             	add    $0x10,%esp
  802d86:	39 cb                	cmp    %ecx,%ebx
  802d88:	74 1b                	je     802da5 <_pipeisclosed+0x54>
		if (n != nn && ret == 1)
  802d8a:	39 45 e4             	cmp    %eax,-0x1c(%ebp)
  802d8d:	75 cf                	jne    802d5e <_pipeisclosed+0xd>
			cprintf("pipe race avoided\n", n, thisenv->env_runs, ret);
  802d8f:	8b 42 58             	mov    0x58(%edx),%eax
  802d92:	6a 01                	push   $0x1
  802d94:	50                   	push   %eax
  802d95:	53                   	push   %ebx
  802d96:	68 19 3d 80 00       	push   $0x803d19
  802d9b:	e8 f7 dd ff ff       	call   800b97 <cprintf>
  802da0:	83 c4 10             	add    $0x10,%esp
  802da3:	eb b9                	jmp    802d5e <_pipeisclosed+0xd>
		ret = pageref(fd) == pageref(p);
  802da5:	39 45 e4             	cmp    %eax,-0x1c(%ebp)
  802da8:	0f 94 c0             	sete   %al
  802dab:	0f b6 c0             	movzbl %al,%eax
}
  802dae:	8d 65 f4             	lea    -0xc(%ebp),%esp
  802db1:	5b                   	pop    %ebx
  802db2:	5e                   	pop    %esi
  802db3:	5f                   	pop    %edi
  802db4:	5d                   	pop    %ebp
  802db5:	c3                   	ret    

00802db6 <devpipe_write>:
{
  802db6:	f3 0f 1e fb          	endbr32 
  802dba:	55                   	push   %ebp
  802dbb:	89 e5                	mov    %esp,%ebp
  802dbd:	57                   	push   %edi
  802dbe:	56                   	push   %esi
  802dbf:	53                   	push   %ebx
  802dc0:	83 ec 28             	sub    $0x28,%esp
  802dc3:	8b 75 08             	mov    0x8(%ebp),%esi
	p = (struct Pipe*) fd2data(fd);
  802dc6:	56                   	push   %esi
  802dc7:	e8 9f ef ff ff       	call   801d6b <fd2data>
  802dcc:	89 c3                	mov    %eax,%ebx
	for (i = 0; i < n; i++) {
  802dce:	83 c4 10             	add    $0x10,%esp
  802dd1:	bf 00 00 00 00       	mov    $0x0,%edi
  802dd6:	3b 7d 10             	cmp    0x10(%ebp),%edi
  802dd9:	74 4f                	je     802e2a <devpipe_write+0x74>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  802ddb:	8b 43 04             	mov    0x4(%ebx),%eax
  802dde:	8b 0b                	mov    (%ebx),%ecx
  802de0:	8d 51 20             	lea    0x20(%ecx),%edx
  802de3:	39 d0                	cmp    %edx,%eax
  802de5:	72 14                	jb     802dfb <devpipe_write+0x45>
			if (_pipeisclosed(fd, p))
  802de7:	89 da                	mov    %ebx,%edx
  802de9:	89 f0                	mov    %esi,%eax
  802deb:	e8 61 ff ff ff       	call   802d51 <_pipeisclosed>
  802df0:	85 c0                	test   %eax,%eax
  802df2:	75 3b                	jne    802e2f <devpipe_write+0x79>
			sys_yield();
  802df4:	e8 8a e8 ff ff       	call   801683 <sys_yield>
  802df9:	eb e0                	jmp    802ddb <devpipe_write+0x25>
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
  802dfb:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  802dfe:	0f b6 0c 39          	movzbl (%ecx,%edi,1),%ecx
  802e02:	88 4d e7             	mov    %cl,-0x19(%ebp)
  802e05:	89 c2                	mov    %eax,%edx
  802e07:	c1 fa 1f             	sar    $0x1f,%edx
  802e0a:	89 d1                	mov    %edx,%ecx
  802e0c:	c1 e9 1b             	shr    $0x1b,%ecx
  802e0f:	8d 14 08             	lea    (%eax,%ecx,1),%edx
  802e12:	83 e2 1f             	and    $0x1f,%edx
  802e15:	29 ca                	sub    %ecx,%edx
  802e17:	0f b6 4d e7          	movzbl -0x19(%ebp),%ecx
  802e1b:	88 4c 13 08          	mov    %cl,0x8(%ebx,%edx,1)
		p->p_wpos++;
  802e1f:	83 c0 01             	add    $0x1,%eax
  802e22:	89 43 04             	mov    %eax,0x4(%ebx)
	for (i = 0; i < n; i++) {
  802e25:	83 c7 01             	add    $0x1,%edi
  802e28:	eb ac                	jmp    802dd6 <devpipe_write+0x20>
	return i;
  802e2a:	8b 45 10             	mov    0x10(%ebp),%eax
  802e2d:	eb 05                	jmp    802e34 <devpipe_write+0x7e>
				return 0;
  802e2f:	b8 00 00 00 00       	mov    $0x0,%eax
}
  802e34:	8d 65 f4             	lea    -0xc(%ebp),%esp
  802e37:	5b                   	pop    %ebx
  802e38:	5e                   	pop    %esi
  802e39:	5f                   	pop    %edi
  802e3a:	5d                   	pop    %ebp
  802e3b:	c3                   	ret    

00802e3c <devpipe_read>:
{
  802e3c:	f3 0f 1e fb          	endbr32 
  802e40:	55                   	push   %ebp
  802e41:	89 e5                	mov    %esp,%ebp
  802e43:	57                   	push   %edi
  802e44:	56                   	push   %esi
  802e45:	53                   	push   %ebx
  802e46:	83 ec 18             	sub    $0x18,%esp
  802e49:	8b 7d 08             	mov    0x8(%ebp),%edi
	p = (struct Pipe*)fd2data(fd);
  802e4c:	57                   	push   %edi
  802e4d:	e8 19 ef ff ff       	call   801d6b <fd2data>
  802e52:	89 c3                	mov    %eax,%ebx
	for (i = 0; i < n; i++) {
  802e54:	83 c4 10             	add    $0x10,%esp
  802e57:	be 00 00 00 00       	mov    $0x0,%esi
  802e5c:	3b 75 10             	cmp    0x10(%ebp),%esi
  802e5f:	75 14                	jne    802e75 <devpipe_read+0x39>
	return i;
  802e61:	8b 45 10             	mov    0x10(%ebp),%eax
  802e64:	eb 02                	jmp    802e68 <devpipe_read+0x2c>
				return i;
  802e66:	89 f0                	mov    %esi,%eax
}
  802e68:	8d 65 f4             	lea    -0xc(%ebp),%esp
  802e6b:	5b                   	pop    %ebx
  802e6c:	5e                   	pop    %esi
  802e6d:	5f                   	pop    %edi
  802e6e:	5d                   	pop    %ebp
  802e6f:	c3                   	ret    
			sys_yield();
  802e70:	e8 0e e8 ff ff       	call   801683 <sys_yield>
		while (p->p_rpos == p->p_wpos) {
  802e75:	8b 03                	mov    (%ebx),%eax
  802e77:	3b 43 04             	cmp    0x4(%ebx),%eax
  802e7a:	75 18                	jne    802e94 <devpipe_read+0x58>
			if (i > 0)
  802e7c:	85 f6                	test   %esi,%esi
  802e7e:	75 e6                	jne    802e66 <devpipe_read+0x2a>
			if (_pipeisclosed(fd, p))
  802e80:	89 da                	mov    %ebx,%edx
  802e82:	89 f8                	mov    %edi,%eax
  802e84:	e8 c8 fe ff ff       	call   802d51 <_pipeisclosed>
  802e89:	85 c0                	test   %eax,%eax
  802e8b:	74 e3                	je     802e70 <devpipe_read+0x34>
				return 0;
  802e8d:	b8 00 00 00 00       	mov    $0x0,%eax
  802e92:	eb d4                	jmp    802e68 <devpipe_read+0x2c>
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
  802e94:	99                   	cltd   
  802e95:	c1 ea 1b             	shr    $0x1b,%edx
  802e98:	01 d0                	add    %edx,%eax
  802e9a:	83 e0 1f             	and    $0x1f,%eax
  802e9d:	29 d0                	sub    %edx,%eax
  802e9f:	0f b6 44 03 08       	movzbl 0x8(%ebx,%eax,1),%eax
  802ea4:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  802ea7:	88 04 31             	mov    %al,(%ecx,%esi,1)
		p->p_rpos++;
  802eaa:	83 03 01             	addl   $0x1,(%ebx)
	for (i = 0; i < n; i++) {
  802ead:	83 c6 01             	add    $0x1,%esi
  802eb0:	eb aa                	jmp    802e5c <devpipe_read+0x20>

00802eb2 <pipe>:
{
  802eb2:	f3 0f 1e fb          	endbr32 
  802eb6:	55                   	push   %ebp
  802eb7:	89 e5                	mov    %esp,%ebp
  802eb9:	56                   	push   %esi
  802eba:	53                   	push   %ebx
  802ebb:	83 ec 1c             	sub    $0x1c,%esp
	if ((r = fd_alloc(&fd0)) < 0
  802ebe:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802ec1:	50                   	push   %eax
  802ec2:	e8 bf ee ff ff       	call   801d86 <fd_alloc>
  802ec7:	89 c3                	mov    %eax,%ebx
  802ec9:	83 c4 10             	add    $0x10,%esp
  802ecc:	85 c0                	test   %eax,%eax
  802ece:	0f 88 23 01 00 00    	js     802ff7 <pipe+0x145>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  802ed4:	83 ec 04             	sub    $0x4,%esp
  802ed7:	68 07 04 00 00       	push   $0x407
  802edc:	ff 75 f4             	pushl  -0xc(%ebp)
  802edf:	6a 00                	push   $0x0
  802ee1:	e8 c0 e7 ff ff       	call   8016a6 <sys_page_alloc>
  802ee6:	89 c3                	mov    %eax,%ebx
  802ee8:	83 c4 10             	add    $0x10,%esp
  802eeb:	85 c0                	test   %eax,%eax
  802eed:	0f 88 04 01 00 00    	js     802ff7 <pipe+0x145>
	if ((r = fd_alloc(&fd1)) < 0
  802ef3:	83 ec 0c             	sub    $0xc,%esp
  802ef6:	8d 45 f0             	lea    -0x10(%ebp),%eax
  802ef9:	50                   	push   %eax
  802efa:	e8 87 ee ff ff       	call   801d86 <fd_alloc>
  802eff:	89 c3                	mov    %eax,%ebx
  802f01:	83 c4 10             	add    $0x10,%esp
  802f04:	85 c0                	test   %eax,%eax
  802f06:	0f 88 db 00 00 00    	js     802fe7 <pipe+0x135>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  802f0c:	83 ec 04             	sub    $0x4,%esp
  802f0f:	68 07 04 00 00       	push   $0x407
  802f14:	ff 75 f0             	pushl  -0x10(%ebp)
  802f17:	6a 00                	push   $0x0
  802f19:	e8 88 e7 ff ff       	call   8016a6 <sys_page_alloc>
  802f1e:	89 c3                	mov    %eax,%ebx
  802f20:	83 c4 10             	add    $0x10,%esp
  802f23:	85 c0                	test   %eax,%eax
  802f25:	0f 88 bc 00 00 00    	js     802fe7 <pipe+0x135>
	va = fd2data(fd0);
  802f2b:	83 ec 0c             	sub    $0xc,%esp
  802f2e:	ff 75 f4             	pushl  -0xc(%ebp)
  802f31:	e8 35 ee ff ff       	call   801d6b <fd2data>
  802f36:	89 c6                	mov    %eax,%esi
	if ((r = sys_page_alloc(0, va, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  802f38:	83 c4 0c             	add    $0xc,%esp
  802f3b:	68 07 04 00 00       	push   $0x407
  802f40:	50                   	push   %eax
  802f41:	6a 00                	push   $0x0
  802f43:	e8 5e e7 ff ff       	call   8016a6 <sys_page_alloc>
  802f48:	89 c3                	mov    %eax,%ebx
  802f4a:	83 c4 10             	add    $0x10,%esp
  802f4d:	85 c0                	test   %eax,%eax
  802f4f:	0f 88 82 00 00 00    	js     802fd7 <pipe+0x125>
	if ((r = sys_page_map(0, va, 0, fd2data(fd1), PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  802f55:	83 ec 0c             	sub    $0xc,%esp
  802f58:	ff 75 f0             	pushl  -0x10(%ebp)
  802f5b:	e8 0b ee ff ff       	call   801d6b <fd2data>
  802f60:	c7 04 24 07 04 00 00 	movl   $0x407,(%esp)
  802f67:	50                   	push   %eax
  802f68:	6a 00                	push   $0x0
  802f6a:	56                   	push   %esi
  802f6b:	6a 00                	push   $0x0
  802f6d:	e8 7b e7 ff ff       	call   8016ed <sys_page_map>
  802f72:	89 c3                	mov    %eax,%ebx
  802f74:	83 c4 20             	add    $0x20,%esp
  802f77:	85 c0                	test   %eax,%eax
  802f79:	78 4e                	js     802fc9 <pipe+0x117>
	fd0->fd_dev_id = devpipe.dev_id;
  802f7b:	a1 3c 40 80 00       	mov    0x80403c,%eax
  802f80:	8b 55 f4             	mov    -0xc(%ebp),%edx
  802f83:	89 02                	mov    %eax,(%edx)
	fd0->fd_omode = O_RDONLY;
  802f85:	8b 55 f4             	mov    -0xc(%ebp),%edx
  802f88:	c7 42 08 00 00 00 00 	movl   $0x0,0x8(%edx)
	fd1->fd_dev_id = devpipe.dev_id;
  802f8f:	8b 55 f0             	mov    -0x10(%ebp),%edx
  802f92:	89 02                	mov    %eax,(%edx)
	fd1->fd_omode = O_WRONLY;
  802f94:	8b 45 f0             	mov    -0x10(%ebp),%eax
  802f97:	c7 40 08 01 00 00 00 	movl   $0x1,0x8(%eax)
	pfd[0] = fd2num(fd0);
  802f9e:	83 ec 0c             	sub    $0xc,%esp
  802fa1:	ff 75 f4             	pushl  -0xc(%ebp)
  802fa4:	e8 ae ed ff ff       	call   801d57 <fd2num>
  802fa9:	8b 4d 08             	mov    0x8(%ebp),%ecx
  802fac:	89 01                	mov    %eax,(%ecx)
	pfd[1] = fd2num(fd1);
  802fae:	83 c4 04             	add    $0x4,%esp
  802fb1:	ff 75 f0             	pushl  -0x10(%ebp)
  802fb4:	e8 9e ed ff ff       	call   801d57 <fd2num>
  802fb9:	8b 4d 08             	mov    0x8(%ebp),%ecx
  802fbc:	89 41 04             	mov    %eax,0x4(%ecx)
	return 0;
  802fbf:	83 c4 10             	add    $0x10,%esp
  802fc2:	bb 00 00 00 00       	mov    $0x0,%ebx
  802fc7:	eb 2e                	jmp    802ff7 <pipe+0x145>
	sys_page_unmap(0, va);
  802fc9:	83 ec 08             	sub    $0x8,%esp
  802fcc:	56                   	push   %esi
  802fcd:	6a 00                	push   $0x0
  802fcf:	e8 5f e7 ff ff       	call   801733 <sys_page_unmap>
  802fd4:	83 c4 10             	add    $0x10,%esp
	sys_page_unmap(0, fd1);
  802fd7:	83 ec 08             	sub    $0x8,%esp
  802fda:	ff 75 f0             	pushl  -0x10(%ebp)
  802fdd:	6a 00                	push   $0x0
  802fdf:	e8 4f e7 ff ff       	call   801733 <sys_page_unmap>
  802fe4:	83 c4 10             	add    $0x10,%esp
	sys_page_unmap(0, fd0);
  802fe7:	83 ec 08             	sub    $0x8,%esp
  802fea:	ff 75 f4             	pushl  -0xc(%ebp)
  802fed:	6a 00                	push   $0x0
  802fef:	e8 3f e7 ff ff       	call   801733 <sys_page_unmap>
  802ff4:	83 c4 10             	add    $0x10,%esp
}
  802ff7:	89 d8                	mov    %ebx,%eax
  802ff9:	8d 65 f8             	lea    -0x8(%ebp),%esp
  802ffc:	5b                   	pop    %ebx
  802ffd:	5e                   	pop    %esi
  802ffe:	5d                   	pop    %ebp
  802fff:	c3                   	ret    

00803000 <pipeisclosed>:
{
  803000:	f3 0f 1e fb          	endbr32 
  803004:	55                   	push   %ebp
  803005:	89 e5                	mov    %esp,%ebp
  803007:	83 ec 20             	sub    $0x20,%esp
	if ((r = fd_lookup(fdnum, &fd)) < 0)
  80300a:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80300d:	50                   	push   %eax
  80300e:	ff 75 08             	pushl  0x8(%ebp)
  803011:	e8 c6 ed ff ff       	call   801ddc <fd_lookup>
  803016:	83 c4 10             	add    $0x10,%esp
  803019:	85 c0                	test   %eax,%eax
  80301b:	78 18                	js     803035 <pipeisclosed+0x35>
	p = (struct Pipe*) fd2data(fd);
  80301d:	83 ec 0c             	sub    $0xc,%esp
  803020:	ff 75 f4             	pushl  -0xc(%ebp)
  803023:	e8 43 ed ff ff       	call   801d6b <fd2data>
  803028:	89 c2                	mov    %eax,%edx
	return _pipeisclosed(fd, p);
  80302a:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80302d:	e8 1f fd ff ff       	call   802d51 <_pipeisclosed>
  803032:	83 c4 10             	add    $0x10,%esp
}
  803035:	c9                   	leave  
  803036:	c3                   	ret    

00803037 <wait>:
#include <inc/lib.h>

// Waits until 'envid' exits.
void
wait(envid_t envid)
{
  803037:	f3 0f 1e fb          	endbr32 
  80303b:	55                   	push   %ebp
  80303c:	89 e5                	mov    %esp,%ebp
  80303e:	56                   	push   %esi
  80303f:	53                   	push   %ebx
  803040:	8b 75 08             	mov    0x8(%ebp),%esi
	const volatile struct Env *e;

	assert(envid != 0);
  803043:	85 f6                	test   %esi,%esi
  803045:	74 13                	je     80305a <wait+0x23>
	e = &envs[ENVX(envid)];
  803047:	89 f3                	mov    %esi,%ebx
  803049:	81 e3 ff 03 00 00    	and    $0x3ff,%ebx
	while (e->env_id == envid && e->env_status != ENV_FREE)
  80304f:	6b db 7c             	imul   $0x7c,%ebx,%ebx
  803052:	81 c3 00 00 c0 ee    	add    $0xeec00000,%ebx
  803058:	eb 1b                	jmp    803075 <wait+0x3e>
	assert(envid != 0);
  80305a:	68 31 3d 80 00       	push   $0x803d31
  80305f:	68 4f 36 80 00       	push   $0x80364f
  803064:	6a 09                	push   $0x9
  803066:	68 3c 3d 80 00       	push   $0x803d3c
  80306b:	e8 40 da ff ff       	call   800ab0 <_panic>
		sys_yield();
  803070:	e8 0e e6 ff ff       	call   801683 <sys_yield>
	while (e->env_id == envid && e->env_status != ENV_FREE)
  803075:	8b 43 48             	mov    0x48(%ebx),%eax
  803078:	39 f0                	cmp    %esi,%eax
  80307a:	75 07                	jne    803083 <wait+0x4c>
  80307c:	8b 43 54             	mov    0x54(%ebx),%eax
  80307f:	85 c0                	test   %eax,%eax
  803081:	75 ed                	jne    803070 <wait+0x39>
}
  803083:	8d 65 f8             	lea    -0x8(%ebp),%esp
  803086:	5b                   	pop    %ebx
  803087:	5e                   	pop    %esi
  803088:	5d                   	pop    %ebp
  803089:	c3                   	ret    

0080308a <set_pgfault_handler>:
// at UXSTACKTOP), and tell the kernel to call the assembly-language
// _pgfault_upcall routine when a page fault occurs.
//
void
set_pgfault_handler(void (*handler)(struct UTrapframe *utf))
{
  80308a:	f3 0f 1e fb          	endbr32 
  80308e:	55                   	push   %ebp
  80308f:	89 e5                	mov    %esp,%ebp
  803091:	83 ec 08             	sub    $0x8,%esp
	int r;

	if (_pgfault_handler == 0) {
  803094:	83 3d 00 70 80 00 00 	cmpl   $0x0,0x807000
  80309b:	74 27                	je     8030c4 <set_pgfault_handler+0x3a>
		if(sys_page_alloc(0,(void *)UXSTACKTOP-PGSIZE,PTE_W|PTE_U|PTE_P)<0)
			panic("set_pgfault_handler:sys_page_alloc failed");
	}

	// Save handler pointer for assembly to call.
	_pgfault_handler = handler;
  80309d:	8b 45 08             	mov    0x8(%ebp),%eax
  8030a0:	a3 00 70 80 00       	mov    %eax,0x807000
	if (sys_env_set_pgfault_upcall(thisenv->env_id,_pgfault_upcall)<0)	
  8030a5:	a1 24 54 80 00       	mov    0x805424,%eax
  8030aa:	8b 40 48             	mov    0x48(%eax),%eax
  8030ad:	83 ec 08             	sub    $0x8,%esp
  8030b0:	68 04 31 80 00       	push   $0x803104
  8030b5:	50                   	push   %eax
  8030b6:	e8 4a e7 ff ff       	call   801805 <sys_env_set_pgfault_upcall>
  8030bb:	83 c4 10             	add    $0x10,%esp
  8030be:	85 c0                	test   %eax,%eax
  8030c0:	78 2e                	js     8030f0 <set_pgfault_handler+0x66>
        panic("set_pgfault_handler:sys_env_set_pgfault_upcall failed");
}
  8030c2:	c9                   	leave  
  8030c3:	c3                   	ret    
		if(sys_page_alloc(0,(void *)UXSTACKTOP-PGSIZE,PTE_W|PTE_U|PTE_P)<0)
  8030c4:	83 ec 04             	sub    $0x4,%esp
  8030c7:	6a 07                	push   $0x7
  8030c9:	68 00 f0 bf ee       	push   $0xeebff000
  8030ce:	6a 00                	push   $0x0
  8030d0:	e8 d1 e5 ff ff       	call   8016a6 <sys_page_alloc>
  8030d5:	83 c4 10             	add    $0x10,%esp
  8030d8:	85 c0                	test   %eax,%eax
  8030da:	79 c1                	jns    80309d <set_pgfault_handler+0x13>
			panic("set_pgfault_handler:sys_page_alloc failed");
  8030dc:	83 ec 04             	sub    $0x4,%esp
  8030df:	68 48 3d 80 00       	push   $0x803d48
  8030e4:	6a 21                	push   $0x21
  8030e6:	68 aa 3d 80 00       	push   $0x803daa
  8030eb:	e8 c0 d9 ff ff       	call   800ab0 <_panic>
        panic("set_pgfault_handler:sys_env_set_pgfault_upcall failed");
  8030f0:	83 ec 04             	sub    $0x4,%esp
  8030f3:	68 74 3d 80 00       	push   $0x803d74
  8030f8:	6a 27                	push   $0x27
  8030fa:	68 aa 3d 80 00       	push   $0x803daa
  8030ff:	e8 ac d9 ff ff       	call   800ab0 <_panic>

00803104 <_pgfault_upcall>:

.text
.globl _pgfault_upcall
_pgfault_upcall:
	// Call the C page fault handler.
	pushl %esp			// function argument: pointer to UTF
  803104:	54                   	push   %esp
	movl _pgfault_handler, %eax
  803105:	a1 00 70 80 00       	mov    0x807000,%eax
	call *%eax
  80310a:	ff d0                	call   *%eax
	addl $4, %esp			// pop function argument
  80310c:	83 c4 04             	add    $0x4,%esp
	// may find that you have to rearrange your code in non-obvious
	// ways as registers become unavailable as scratch space.
	//
	// LAB 4: Your code here.
	//首先把此时的eip指针下移48个字节因为UTrapFrame的大小是48个字节
	movl 48(%esp), %ebp
  80310f:	8b 6c 24 30          	mov    0x30(%esp),%ebp
    subl $4, %ebp		// UTrapFrame.utf_esp - 4 and store back 这里是由于之前预留了4个字节。
  803113:	83 ed 04             	sub    $0x4,%ebp
    movl %ebp, 48(%esp)	// 返回上一次的esp位置。
  803116:	89 6c 24 30          	mov    %ebp,0x30(%esp)

	// Restore the trap-time registers.  After you do this, you
	// can no longer modify any general-purpose registers.
	// LAB 4: Your code here.
	movl 40(%esp), %eax 
  80311a:	8b 44 24 28          	mov    0x28(%esp),%eax
    movl %eax, (%ebp)
  80311e:	89 45 00             	mov    %eax,0x0(%ebp)

	// Restore eflags from the stack.  After you do this, you can
	// no longer use arithmetic operations or anything else that
	// modifies eflags.
	// LAB 4: Your code here.
	addl $0x8, %esp         // Set %esp to the end of struct PushRegs
  803121:	83 c4 08             	add    $0x8,%esp
	popal                   // Restore the trap-time registers.(struct PushRegs)
  803124:	61                   	popa   

	// Switch back to the adjusted trap-time stack.
	// LAB 4: Your code here.
	addl $0x4, %esp         // now we are located at trap-time eip,so we have to increment %esp with 4.【跳过eip】
  803125:	83 c4 04             	add    $0x4,%esp
	popfl                   // Restore eflags register.	【pop eflags】
  803128:	9d                   	popf   
	popl %esp               // Just restore the adjusted trap-time stack pointer.
  803129:	5c                   	pop    %esp
							// 恢复esp

	// Return to re-execute the instruction that faulted.
	// LAB 4: Your code here.
	ret                     // We are now on the trap-time stack,since we have saved trap-time eip above trap-time esp,ret instruction will pop this trap-time eip to register %eip which known as PC at this time.Thus,we can return to re-execute the instruction that faulted.
  80312a:	c3                   	ret    

0080312b <ipc_recv>:
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value, since that's
//   a perfectly valid place to map a page.)
int32_t
ipc_recv(envid_t *from_env_store, void *pg, int *perm_store)
{
  80312b:	f3 0f 1e fb          	endbr32 
  80312f:	55                   	push   %ebp
  803130:	89 e5                	mov    %esp,%ebp
  803132:	56                   	push   %esi
  803133:	53                   	push   %ebx
  803134:	8b 75 08             	mov    0x8(%ebp),%esi
  803137:	8b 45 0c             	mov    0xc(%ebp),%eax
  80313a:	8b 5d 10             	mov    0x10(%ebp),%ebx
	// LAB 4: Your code here.
	int error;
	if(!pg)pg = (void *)UTOP; // 如果设置为UTOP，这个值其实可以比UTOP大，设置为这个值认为pg无效了，不会进行页面传递【共享页面的设置】，而是只进行值value的传递。
  80313d:	85 c0                	test   %eax,%eax
  80313f:	ba 00 00 c0 ee       	mov    $0xeec00000,%edx
  803144:	0f 44 c2             	cmove  %edx,%eax
	if((error = sys_ipc_recv(pg)) < 0){
  803147:	83 ec 0c             	sub    $0xc,%esp
  80314a:	50                   	push   %eax
  80314b:	e8 22 e7 ff ff       	call   801872 <sys_ipc_recv>
  803150:	83 c4 10             	add    $0x10,%esp
  803153:	85 c0                	test   %eax,%eax
  803155:	78 3f                	js     803196 <ipc_recv+0x6b>
		if(from_env_store)*from_env_store = 0;
		if(perm_store)*perm_store = 0;
		return error;
	}

	thisenv = &envs[ENVX(sys_getenvid())]; // for lab4's challenge sfork().
  803157:	e8 04 e5 ff ff       	call   801660 <sys_getenvid>
  80315c:	25 ff 03 00 00       	and    $0x3ff,%eax
  803161:	6b d0 7c             	imul   $0x7c,%eax,%edx
  803164:	81 c2 00 00 c0 ee    	add    $0xeec00000,%edx
  80316a:	89 15 24 54 80 00    	mov    %edx,0x805424

	if(from_env_store)*from_env_store = thisenv->env_ipc_from;
  803170:	85 f6                	test   %esi,%esi
  803172:	74 05                	je     803179 <ipc_recv+0x4e>
  803174:	8b 42 74             	mov    0x74(%edx),%eax
  803177:	89 06                	mov    %eax,(%esi)
	if(perm_store)*perm_store = thisenv->env_ipc_perm;
  803179:	85 db                	test   %ebx,%ebx
  80317b:	74 0a                	je     803187 <ipc_recv+0x5c>
  80317d:	a1 24 54 80 00       	mov    0x805424,%eax
  803182:	8b 40 78             	mov    0x78(%eax),%eax
  803185:	89 03                	mov    %eax,(%ebx)
	return thisenv->env_ipc_value;
  803187:	a1 24 54 80 00       	mov    0x805424,%eax
  80318c:	8b 40 70             	mov    0x70(%eax),%eax
}
  80318f:	8d 65 f8             	lea    -0x8(%ebp),%esp
  803192:	5b                   	pop    %ebx
  803193:	5e                   	pop    %esi
  803194:	5d                   	pop    %ebp
  803195:	c3                   	ret    
		if(from_env_store)*from_env_store = 0;
  803196:	85 f6                	test   %esi,%esi
  803198:	74 06                	je     8031a0 <ipc_recv+0x75>
  80319a:	c7 06 00 00 00 00    	movl   $0x0,(%esi)
		if(perm_store)*perm_store = 0;
  8031a0:	85 db                	test   %ebx,%ebx
  8031a2:	74 eb                	je     80318f <ipc_recv+0x64>
  8031a4:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
  8031aa:	eb e3                	jmp    80318f <ipc_recv+0x64>

008031ac <ipc_send>:
//   Use sys_yield() to be CPU-friendly.
//   If 'pg' is null, pass sys_ipc_try_send a value that it will understand
//   as meaning "no page".  (Zero is not the right value.)
void
ipc_send(envid_t to_env, uint32_t val, void *pg, int perm)
{
  8031ac:	f3 0f 1e fb          	endbr32 
  8031b0:	55                   	push   %ebp
  8031b1:	89 e5                	mov    %esp,%ebp
  8031b3:	57                   	push   %edi
  8031b4:	56                   	push   %esi
  8031b5:	53                   	push   %ebx
  8031b6:	83 ec 0c             	sub    $0xc,%esp
  8031b9:	8b 7d 08             	mov    0x8(%ebp),%edi
  8031bc:	8b 75 0c             	mov    0xc(%ebp),%esi
  8031bf:	8b 5d 10             	mov    0x10(%ebp),%ebx
	// LAB 4: Your code here.
	if(!pg)pg = (void *)UTOP; // 不会进行页面共享，只会sending message。
  8031c2:	85 db                	test   %ebx,%ebx
  8031c4:	b8 00 00 c0 ee       	mov    $0xeec00000,%eax
  8031c9:	0f 44 d8             	cmove  %eax,%ebx
	int error;
	// Keep trying until it succeeds.
	while((error = sys_ipc_try_send(to_env, val, pg, perm)) < 0){
  8031cc:	ff 75 14             	pushl  0x14(%ebp)
  8031cf:	53                   	push   %ebx
  8031d0:	56                   	push   %esi
  8031d1:	57                   	push   %edi
  8031d2:	e8 74 e6 ff ff       	call   80184b <sys_ipc_try_send>
  8031d7:	83 c4 10             	add    $0x10,%esp
  8031da:	85 c0                	test   %eax,%eax
  8031dc:	79 1e                	jns    8031fc <ipc_send+0x50>
        //如果error是没有接收者，那么就会继续尝试send
		if(error != -E_IPC_NOT_RECV){
  8031de:	83 f8 f9             	cmp    $0xfffffff9,%eax
  8031e1:	75 07                	jne    8031ea <ipc_send+0x3e>
			panic("sys_ipc_try_send:%e", error);
		}
        //但是不是一味的占用cpu，而是尝试一次就释放CPU，等待再次被调度，才会重新send，寻找receiver。
		sys_yield(); // To be CPU-friendly.
  8031e3:	e8 9b e4 ff ff       	call   801683 <sys_yield>
  8031e8:	eb e2                	jmp    8031cc <ipc_send+0x20>
			panic("sys_ipc_try_send:%e", error);
  8031ea:	50                   	push   %eax
  8031eb:	68 b8 3d 80 00       	push   $0x803db8
  8031f0:	6a 3b                	push   $0x3b
  8031f2:	68 cc 3d 80 00       	push   $0x803dcc
  8031f7:	e8 b4 d8 ff ff       	call   800ab0 <_panic>
	}
}
  8031fc:	8d 65 f4             	lea    -0xc(%ebp),%esp
  8031ff:	5b                   	pop    %ebx
  803200:	5e                   	pop    %esi
  803201:	5f                   	pop    %edi
  803202:	5d                   	pop    %ebp
  803203:	c3                   	ret    

00803204 <ipc_find_env>:
// Find the first environment of the given type.  We'll use this to
// find special environments.
// Returns 0 if no such environment exists.
envid_t
ipc_find_env(enum EnvType type)
{
  803204:	f3 0f 1e fb          	endbr32 
  803208:	55                   	push   %ebp
  803209:	89 e5                	mov    %esp,%ebp
  80320b:	8b 4d 08             	mov    0x8(%ebp),%ecx
	int i;
	for (i = 0; i < NENV; i++)
  80320e:	b8 00 00 00 00       	mov    $0x0,%eax
		if (envs[i].env_type == type)
  803213:	6b d0 7c             	imul   $0x7c,%eax,%edx
  803216:	81 c2 00 00 c0 ee    	add    $0xeec00000,%edx
  80321c:	8b 52 50             	mov    0x50(%edx),%edx
  80321f:	39 ca                	cmp    %ecx,%edx
  803221:	74 11                	je     803234 <ipc_find_env+0x30>
	for (i = 0; i < NENV; i++)
  803223:	83 c0 01             	add    $0x1,%eax
  803226:	3d 00 04 00 00       	cmp    $0x400,%eax
  80322b:	75 e6                	jne    803213 <ipc_find_env+0xf>
			return envs[i].env_id;
	return 0;
  80322d:	b8 00 00 00 00       	mov    $0x0,%eax
  803232:	eb 0b                	jmp    80323f <ipc_find_env+0x3b>
			return envs[i].env_id;
  803234:	6b c0 7c             	imul   $0x7c,%eax,%eax
  803237:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  80323c:	8b 40 48             	mov    0x48(%eax),%eax
}
  80323f:	5d                   	pop    %ebp
  803240:	c3                   	ret    

00803241 <pageref>:
#include <inc/lib.h>

int
pageref(void *v)
{
  803241:	f3 0f 1e fb          	endbr32 
  803245:	55                   	push   %ebp
  803246:	89 e5                	mov    %esp,%ebp
  803248:	8b 45 08             	mov    0x8(%ebp),%eax
	pte_t pte;

	if (!(uvpd[PDX(v)] & PTE_P))
  80324b:	89 c2                	mov    %eax,%edx
  80324d:	c1 ea 16             	shr    $0x16,%edx
  803250:	8b 0c 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%ecx
		return 0;
  803257:	ba 00 00 00 00       	mov    $0x0,%edx
	if (!(uvpd[PDX(v)] & PTE_P))
  80325c:	f6 c1 01             	test   $0x1,%cl
  80325f:	74 1c                	je     80327d <pageref+0x3c>
	pte = uvpt[PGNUM(v)];
  803261:	c1 e8 0c             	shr    $0xc,%eax
  803264:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
	if (!(pte & PTE_P))
  80326b:	a8 01                	test   $0x1,%al
  80326d:	74 0e                	je     80327d <pageref+0x3c>
		return 0;
	return pages[PGNUM(pte)].pp_ref;
  80326f:	c1 e8 0c             	shr    $0xc,%eax
  803272:	0f b7 14 c5 04 00 00 	movzwl -0x10fffffc(,%eax,8),%edx
  803279:	ef 
  80327a:	0f b7 d2             	movzwl %dx,%edx
}
  80327d:	89 d0                	mov    %edx,%eax
  80327f:	5d                   	pop    %ebp
  803280:	c3                   	ret    
  803281:	66 90                	xchg   %ax,%ax
  803283:	66 90                	xchg   %ax,%ax
  803285:	66 90                	xchg   %ax,%ax
  803287:	66 90                	xchg   %ax,%ax
  803289:	66 90                	xchg   %ax,%ax
  80328b:	66 90                	xchg   %ax,%ax
  80328d:	66 90                	xchg   %ax,%ax
  80328f:	90                   	nop

00803290 <__udivdi3>:
  803290:	f3 0f 1e fb          	endbr32 
  803294:	55                   	push   %ebp
  803295:	57                   	push   %edi
  803296:	56                   	push   %esi
  803297:	53                   	push   %ebx
  803298:	83 ec 1c             	sub    $0x1c,%esp
  80329b:	8b 54 24 3c          	mov    0x3c(%esp),%edx
  80329f:	8b 6c 24 30          	mov    0x30(%esp),%ebp
  8032a3:	8b 74 24 34          	mov    0x34(%esp),%esi
  8032a7:	8b 5c 24 38          	mov    0x38(%esp),%ebx
  8032ab:	85 d2                	test   %edx,%edx
  8032ad:	75 19                	jne    8032c8 <__udivdi3+0x38>
  8032af:	39 f3                	cmp    %esi,%ebx
  8032b1:	76 4d                	jbe    803300 <__udivdi3+0x70>
  8032b3:	31 ff                	xor    %edi,%edi
  8032b5:	89 e8                	mov    %ebp,%eax
  8032b7:	89 f2                	mov    %esi,%edx
  8032b9:	f7 f3                	div    %ebx
  8032bb:	89 fa                	mov    %edi,%edx
  8032bd:	83 c4 1c             	add    $0x1c,%esp
  8032c0:	5b                   	pop    %ebx
  8032c1:	5e                   	pop    %esi
  8032c2:	5f                   	pop    %edi
  8032c3:	5d                   	pop    %ebp
  8032c4:	c3                   	ret    
  8032c5:	8d 76 00             	lea    0x0(%esi),%esi
  8032c8:	39 f2                	cmp    %esi,%edx
  8032ca:	76 14                	jbe    8032e0 <__udivdi3+0x50>
  8032cc:	31 ff                	xor    %edi,%edi
  8032ce:	31 c0                	xor    %eax,%eax
  8032d0:	89 fa                	mov    %edi,%edx
  8032d2:	83 c4 1c             	add    $0x1c,%esp
  8032d5:	5b                   	pop    %ebx
  8032d6:	5e                   	pop    %esi
  8032d7:	5f                   	pop    %edi
  8032d8:	5d                   	pop    %ebp
  8032d9:	c3                   	ret    
  8032da:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  8032e0:	0f bd fa             	bsr    %edx,%edi
  8032e3:	83 f7 1f             	xor    $0x1f,%edi
  8032e6:	75 48                	jne    803330 <__udivdi3+0xa0>
  8032e8:	39 f2                	cmp    %esi,%edx
  8032ea:	72 06                	jb     8032f2 <__udivdi3+0x62>
  8032ec:	31 c0                	xor    %eax,%eax
  8032ee:	39 eb                	cmp    %ebp,%ebx
  8032f0:	77 de                	ja     8032d0 <__udivdi3+0x40>
  8032f2:	b8 01 00 00 00       	mov    $0x1,%eax
  8032f7:	eb d7                	jmp    8032d0 <__udivdi3+0x40>
  8032f9:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  803300:	89 d9                	mov    %ebx,%ecx
  803302:	85 db                	test   %ebx,%ebx
  803304:	75 0b                	jne    803311 <__udivdi3+0x81>
  803306:	b8 01 00 00 00       	mov    $0x1,%eax
  80330b:	31 d2                	xor    %edx,%edx
  80330d:	f7 f3                	div    %ebx
  80330f:	89 c1                	mov    %eax,%ecx
  803311:	31 d2                	xor    %edx,%edx
  803313:	89 f0                	mov    %esi,%eax
  803315:	f7 f1                	div    %ecx
  803317:	89 c6                	mov    %eax,%esi
  803319:	89 e8                	mov    %ebp,%eax
  80331b:	89 f7                	mov    %esi,%edi
  80331d:	f7 f1                	div    %ecx
  80331f:	89 fa                	mov    %edi,%edx
  803321:	83 c4 1c             	add    $0x1c,%esp
  803324:	5b                   	pop    %ebx
  803325:	5e                   	pop    %esi
  803326:	5f                   	pop    %edi
  803327:	5d                   	pop    %ebp
  803328:	c3                   	ret    
  803329:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  803330:	89 f9                	mov    %edi,%ecx
  803332:	b8 20 00 00 00       	mov    $0x20,%eax
  803337:	29 f8                	sub    %edi,%eax
  803339:	d3 e2                	shl    %cl,%edx
  80333b:	89 54 24 08          	mov    %edx,0x8(%esp)
  80333f:	89 c1                	mov    %eax,%ecx
  803341:	89 da                	mov    %ebx,%edx
  803343:	d3 ea                	shr    %cl,%edx
  803345:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  803349:	09 d1                	or     %edx,%ecx
  80334b:	89 f2                	mov    %esi,%edx
  80334d:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  803351:	89 f9                	mov    %edi,%ecx
  803353:	d3 e3                	shl    %cl,%ebx
  803355:	89 c1                	mov    %eax,%ecx
  803357:	d3 ea                	shr    %cl,%edx
  803359:	89 f9                	mov    %edi,%ecx
  80335b:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  80335f:	89 eb                	mov    %ebp,%ebx
  803361:	d3 e6                	shl    %cl,%esi
  803363:	89 c1                	mov    %eax,%ecx
  803365:	d3 eb                	shr    %cl,%ebx
  803367:	09 de                	or     %ebx,%esi
  803369:	89 f0                	mov    %esi,%eax
  80336b:	f7 74 24 08          	divl   0x8(%esp)
  80336f:	89 d6                	mov    %edx,%esi
  803371:	89 c3                	mov    %eax,%ebx
  803373:	f7 64 24 0c          	mull   0xc(%esp)
  803377:	39 d6                	cmp    %edx,%esi
  803379:	72 15                	jb     803390 <__udivdi3+0x100>
  80337b:	89 f9                	mov    %edi,%ecx
  80337d:	d3 e5                	shl    %cl,%ebp
  80337f:	39 c5                	cmp    %eax,%ebp
  803381:	73 04                	jae    803387 <__udivdi3+0xf7>
  803383:	39 d6                	cmp    %edx,%esi
  803385:	74 09                	je     803390 <__udivdi3+0x100>
  803387:	89 d8                	mov    %ebx,%eax
  803389:	31 ff                	xor    %edi,%edi
  80338b:	e9 40 ff ff ff       	jmp    8032d0 <__udivdi3+0x40>
  803390:	8d 43 ff             	lea    -0x1(%ebx),%eax
  803393:	31 ff                	xor    %edi,%edi
  803395:	e9 36 ff ff ff       	jmp    8032d0 <__udivdi3+0x40>
  80339a:	66 90                	xchg   %ax,%ax
  80339c:	66 90                	xchg   %ax,%ax
  80339e:	66 90                	xchg   %ax,%ax

008033a0 <__umoddi3>:
  8033a0:	f3 0f 1e fb          	endbr32 
  8033a4:	55                   	push   %ebp
  8033a5:	57                   	push   %edi
  8033a6:	56                   	push   %esi
  8033a7:	53                   	push   %ebx
  8033a8:	83 ec 1c             	sub    $0x1c,%esp
  8033ab:	8b 44 24 3c          	mov    0x3c(%esp),%eax
  8033af:	8b 74 24 30          	mov    0x30(%esp),%esi
  8033b3:	8b 5c 24 34          	mov    0x34(%esp),%ebx
  8033b7:	8b 7c 24 38          	mov    0x38(%esp),%edi
  8033bb:	85 c0                	test   %eax,%eax
  8033bd:	75 19                	jne    8033d8 <__umoddi3+0x38>
  8033bf:	39 df                	cmp    %ebx,%edi
  8033c1:	76 5d                	jbe    803420 <__umoddi3+0x80>
  8033c3:	89 f0                	mov    %esi,%eax
  8033c5:	89 da                	mov    %ebx,%edx
  8033c7:	f7 f7                	div    %edi
  8033c9:	89 d0                	mov    %edx,%eax
  8033cb:	31 d2                	xor    %edx,%edx
  8033cd:	83 c4 1c             	add    $0x1c,%esp
  8033d0:	5b                   	pop    %ebx
  8033d1:	5e                   	pop    %esi
  8033d2:	5f                   	pop    %edi
  8033d3:	5d                   	pop    %ebp
  8033d4:	c3                   	ret    
  8033d5:	8d 76 00             	lea    0x0(%esi),%esi
  8033d8:	89 f2                	mov    %esi,%edx
  8033da:	39 d8                	cmp    %ebx,%eax
  8033dc:	76 12                	jbe    8033f0 <__umoddi3+0x50>
  8033de:	89 f0                	mov    %esi,%eax
  8033e0:	89 da                	mov    %ebx,%edx
  8033e2:	83 c4 1c             	add    $0x1c,%esp
  8033e5:	5b                   	pop    %ebx
  8033e6:	5e                   	pop    %esi
  8033e7:	5f                   	pop    %edi
  8033e8:	5d                   	pop    %ebp
  8033e9:	c3                   	ret    
  8033ea:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  8033f0:	0f bd e8             	bsr    %eax,%ebp
  8033f3:	83 f5 1f             	xor    $0x1f,%ebp
  8033f6:	75 50                	jne    803448 <__umoddi3+0xa8>
  8033f8:	39 d8                	cmp    %ebx,%eax
  8033fa:	0f 82 e0 00 00 00    	jb     8034e0 <__umoddi3+0x140>
  803400:	89 d9                	mov    %ebx,%ecx
  803402:	39 f7                	cmp    %esi,%edi
  803404:	0f 86 d6 00 00 00    	jbe    8034e0 <__umoddi3+0x140>
  80340a:	89 d0                	mov    %edx,%eax
  80340c:	89 ca                	mov    %ecx,%edx
  80340e:	83 c4 1c             	add    $0x1c,%esp
  803411:	5b                   	pop    %ebx
  803412:	5e                   	pop    %esi
  803413:	5f                   	pop    %edi
  803414:	5d                   	pop    %ebp
  803415:	c3                   	ret    
  803416:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  80341d:	8d 76 00             	lea    0x0(%esi),%esi
  803420:	89 fd                	mov    %edi,%ebp
  803422:	85 ff                	test   %edi,%edi
  803424:	75 0b                	jne    803431 <__umoddi3+0x91>
  803426:	b8 01 00 00 00       	mov    $0x1,%eax
  80342b:	31 d2                	xor    %edx,%edx
  80342d:	f7 f7                	div    %edi
  80342f:	89 c5                	mov    %eax,%ebp
  803431:	89 d8                	mov    %ebx,%eax
  803433:	31 d2                	xor    %edx,%edx
  803435:	f7 f5                	div    %ebp
  803437:	89 f0                	mov    %esi,%eax
  803439:	f7 f5                	div    %ebp
  80343b:	89 d0                	mov    %edx,%eax
  80343d:	31 d2                	xor    %edx,%edx
  80343f:	eb 8c                	jmp    8033cd <__umoddi3+0x2d>
  803441:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  803448:	89 e9                	mov    %ebp,%ecx
  80344a:	ba 20 00 00 00       	mov    $0x20,%edx
  80344f:	29 ea                	sub    %ebp,%edx
  803451:	d3 e0                	shl    %cl,%eax
  803453:	89 44 24 08          	mov    %eax,0x8(%esp)
  803457:	89 d1                	mov    %edx,%ecx
  803459:	89 f8                	mov    %edi,%eax
  80345b:	d3 e8                	shr    %cl,%eax
  80345d:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  803461:	89 54 24 04          	mov    %edx,0x4(%esp)
  803465:	8b 54 24 04          	mov    0x4(%esp),%edx
  803469:	09 c1                	or     %eax,%ecx
  80346b:	89 d8                	mov    %ebx,%eax
  80346d:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  803471:	89 e9                	mov    %ebp,%ecx
  803473:	d3 e7                	shl    %cl,%edi
  803475:	89 d1                	mov    %edx,%ecx
  803477:	d3 e8                	shr    %cl,%eax
  803479:	89 e9                	mov    %ebp,%ecx
  80347b:	89 7c 24 0c          	mov    %edi,0xc(%esp)
  80347f:	d3 e3                	shl    %cl,%ebx
  803481:	89 c7                	mov    %eax,%edi
  803483:	89 d1                	mov    %edx,%ecx
  803485:	89 f0                	mov    %esi,%eax
  803487:	d3 e8                	shr    %cl,%eax
  803489:	89 e9                	mov    %ebp,%ecx
  80348b:	89 fa                	mov    %edi,%edx
  80348d:	d3 e6                	shl    %cl,%esi
  80348f:	09 d8                	or     %ebx,%eax
  803491:	f7 74 24 08          	divl   0x8(%esp)
  803495:	89 d1                	mov    %edx,%ecx
  803497:	89 f3                	mov    %esi,%ebx
  803499:	f7 64 24 0c          	mull   0xc(%esp)
  80349d:	89 c6                	mov    %eax,%esi
  80349f:	89 d7                	mov    %edx,%edi
  8034a1:	39 d1                	cmp    %edx,%ecx
  8034a3:	72 06                	jb     8034ab <__umoddi3+0x10b>
  8034a5:	75 10                	jne    8034b7 <__umoddi3+0x117>
  8034a7:	39 c3                	cmp    %eax,%ebx
  8034a9:	73 0c                	jae    8034b7 <__umoddi3+0x117>
  8034ab:	2b 44 24 0c          	sub    0xc(%esp),%eax
  8034af:	1b 54 24 08          	sbb    0x8(%esp),%edx
  8034b3:	89 d7                	mov    %edx,%edi
  8034b5:	89 c6                	mov    %eax,%esi
  8034b7:	89 ca                	mov    %ecx,%edx
  8034b9:	0f b6 4c 24 04       	movzbl 0x4(%esp),%ecx
  8034be:	29 f3                	sub    %esi,%ebx
  8034c0:	19 fa                	sbb    %edi,%edx
  8034c2:	89 d0                	mov    %edx,%eax
  8034c4:	d3 e0                	shl    %cl,%eax
  8034c6:	89 e9                	mov    %ebp,%ecx
  8034c8:	d3 eb                	shr    %cl,%ebx
  8034ca:	d3 ea                	shr    %cl,%edx
  8034cc:	09 d8                	or     %ebx,%eax
  8034ce:	83 c4 1c             	add    $0x1c,%esp
  8034d1:	5b                   	pop    %ebx
  8034d2:	5e                   	pop    %esi
  8034d3:	5f                   	pop    %edi
  8034d4:	5d                   	pop    %ebp
  8034d5:	c3                   	ret    
  8034d6:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  8034dd:	8d 76 00             	lea    0x0(%esi),%esi
  8034e0:	29 fe                	sub    %edi,%esi
  8034e2:	19 c3                	sbb    %eax,%ebx
  8034e4:	89 f2                	mov    %esi,%edx
  8034e6:	89 d9                	mov    %ebx,%ecx
  8034e8:	e9 1d ff ff ff       	jmp    80340a <__umoddi3+0x6a>
